include/Localization/Localization.php
\Localization
Localization manager
- Api
Properties
$availableCharsets= 'array(
'BIG-5', //Taiwan and Hong Kong
/*'CP866' // ms-dos Cyrillic */
/*'CP949' //Microsoft Korean */
'CP1251', //MS Cyrillic
'CP1252', //MS Western European & US
'EUC-CN', //Simplified Chinese GB2312
'EUC-JP', //Unix Japanese
'EUC-KR', //Korean
'EUC-TW', //Taiwanese
'ISO-2022-JP', //Japanese
'ISO-2022-KR', //Korean
'ISO-8859-1', //Western European and US
'ISO-8859-2', //Central and Eastern European
'ISO-8859-3', //Latin 3
'ISO-8859-4', //Latin 4
'ISO-8859-5', //Cyrillic
'ISO-8859-6', //Arabic
'ISO-8859-7', //Greek
'ISO-8859-8', //Hebrew
'ISO-8859-9', //Latin 5
'ISO-8859-10', //Latin 6
'ISO-8859-13', //Latin 7
'ISO-8859-14', //Latin 8
'ISO-8859-15', //Latin 9
'KOI8-R', //Cyrillic Russian
'KOI8-U', //Cyrillic Ukranian
'SJIS', //MS Japanese
'UTF-8', //UTF-8
)'
array(
'BIG-5', //Taiwan and Hong Kong
/*'CP866' // ms-dos Cyrillic */
/*'CP949' //Microsoft Korean */
'CP1251', //MS Cyrillic
'CP1252', //MS Western European & US
'EUC-CN', //Simplified Chinese GB2312
'EUC-JP', //Unix Japanese
'EUC-KR', //Korean
'EUC-TW', //Taiwanese
'ISO-2022-JP', //Japanese
'ISO-2022-KR', //Korean
'ISO-8859-1', //Western European and US
'ISO-8859-2', //Central and Eastern European
'ISO-8859-3', //Latin 3
'ISO-8859-4', //Latin 4
'ISO-8859-5', //Cyrillic
'ISO-8859-6', //Arabic
'ISO-8859-7', //Greek
'ISO-8859-8', //Hebrew
'ISO-8859-9', //Latin 5
'ISO-8859-10', //Latin 6
'ISO-8859-13', //Latin 7
'ISO-8859-14', //Latin 8
'ISO-8859-15', //Latin 9
'KOI8-R', //Cyrillic Russian
'KOI8-U', //Cyrillic Ukranian
'SJIS', //MS Japanese
'UTF-8', //UTF-8
)
Details- Type
- n/a
$iconvCharsetMap= 'array(
'KS_C_5601-1987' => 'CP949',
'ISO-8859-8-I' => 'ISO-8859-8'
)'
array(
'KS_C_5601-1987' => 'CP949',
'ISO-8859-8-I' => 'ISO-8859-8'
)
Details- Type
- n/a
$invalidNameFormatUpgradeFilename= ''upgradeInvalidLocaleNameFormat.php''
'upgradeInvalidLocaleNameFormat.php'
Details- Type
- n/a
Methods
createInvalidLocaleNameFormatUpgradeNotice(
)
:
void
Creates the file that is created when there is an invalid name format during an upgrade
detectCharset(
\$str $str, \$strict $strict
=
false
)
:
string
Attempts to detect the charset used in the string
Name | Type | Description |
---|---|---|
$str | \$str | string |
$strict | \$strict | bool default false (use strict encoding?) |
Type | Description |
---|---|
string |
getCharsetSelect(
)
:
void
returns an array of charsets with keys for available translations; appropriate for get_select_options_with_id()
getCurrencies(
)
:
array
getter for currencies array
Type | Description |
---|---|
array | $this->currencies returns array( id => array(name => X, etc |
getDefaultCurrencies(
)
:
array
retrieves default OOTB currencies for sugar_config and installer.
Type | Description |
---|---|
array | ret Array of default currencies keyed by ISO4217 code |
getExportCharset(
string $charset
=
'', $user
=
null
)
:
string
returns the charset preferred in descending order: User, Sugar Config, DEFAULT
Name | Type | Description |
---|---|---|
$charset | string | charset to override ALL, pass a valid charset here |
$user |
Type | Description |
---|---|
string | charset the chosen character set |
getLocaleConfigDefaults(
)
:
array
returns an array of Sugar Config defaults that are determined by locale settings
Type | Description |
---|---|
array |
getLocaleFormatMacro(
$user
=
null
)
:
string
get's the Name format macro string, preferring $current_user
Name | Type | Description |
---|---|---|
$user |
Type | Description |
---|---|
string | format Name Format macro for locale |
getLocaleFormattedName(
string $firstName, string $lastName, string $salutationKey
=
'', string $title
=
'', string $format
=
"", object $user
=
null, bool $returnEmptyStringIfEmpty
=
false
)
:
string
returns formatted name according to $current_user's locale settings
Name | Type | Description |
---|---|---|
$firstName | string | firstName |
$lastName | string | lastName |
$salutationKey | string | salutation |
$title | string | title |
$format | string | format If a particular format is desired, then pass this optional parameter as a simple string. sfl is "Salutation FirstName LastName", "l, f s" is "LastName[comma][space]FirstName[space]Salutation" |
$user | object | user object |
$returnEmptyStringIfEmpty | bool | returnEmptyStringIfEmpty true if we should return back an empty string rather than a single space when the formatted name would be blank |
Type | Description |
---|---|
string | formattedName |
getLocaleFormattedNumber(
string $number, string $currencySymbol
=
'', bool $is_currency
=
true, $user
=
null
)
:
string
returns a number formatted by user preference or system default
Name | Type | Description |
---|---|---|
$number | string | number Number to be formatted and returned |
$currencySymbol | string | currencySymbol Currency symbol if override is necessary |
$is_currency | bool | is_currency Flag to also return the currency symbol |
$user |
Type | Description |
---|---|
string | Formatted number |
getNameJs(
string $first
=
'', string $last
=
'', string $salutation
=
'', $title
=
''
)
:
string
outputs some simple Javascript to show a preview of Name format in "My Account" and "Admin->Localization"
Name | Type | Description |
---|---|---|
$first | string | first First Name, use app_strings default if not specified |
$last | string | last Last Name, use app_strings default if not specified |
$salutation | string | salutation Saluation, use app_strings default if not specified |
$title |
Type | Description |
---|---|
string | some Javascript |
getOutboundEmailCharset(
$user
=
null
)
:
string
returns the charset preferred in descending order: User, Sugar Config, DEFAULT
Name | Type | Description |
---|---|---|
$user |
Type | Description |
---|---|
string | charset the chosen character set |
getPrecedentPreference(
string $prefName, object $user
=
null, $sugarConfigPrefName
=
''
)
:
string
abstraction of precedence
Name | Type | Description |
---|---|---|
$prefName | string | prefName Name of preference to retrieve based on overrides |
$user | object | user User in focus, default null (current_user) |
$sugarConfigPrefName |
Type | Description |
---|---|
string | pref Most significant preference |
getUsableLocaleNameOptions(
array $options
)
:
array
Creates dropdown items that have localized example names while filtering out invalid formats
Name | Type | Description |
---|---|---|
$options | array | un-prettied dropdown list |
Type | Description |
---|---|
array | array of dropdown options |
invalidLocaleNameFormatUpgrade(
)
:
bool
Checks to see if there was an invalid Name Format encountered during the upgrade
Type | Description |
---|---|
bool | true if there was an invalid name, false if all went well. |
isAllowedNameFormat(
$name_format
)
:
bool
Checks to see that the characters in $name_format are allowed: s, f, l, space/tab or punctuation
Name | Type | Description |
---|---|---|
$name_format |
Type | Description |
---|---|
bool |
prepBeanForExport(
\bean $bean
)
:
\bean
prepares a bean for export by translating any text fields into the export character set
Name | Type | Description |
---|---|---|
$bean | \bean | object A SugarBean |
Type | Description |
---|---|
\bean | object The bean with translated strings |
removeInvalidLocaleNameFormatUpgradeNotice(
)
:
void
Removes the file that is created when there is an invalid name format during an upgrade
translateCharset(
string $string, string $fromCharset, string $toCharset
=
'UTF-8', bool $forceIconv
=
false
)
:
string
translates a character set from one encoding to another encoding
Name | Type | Description |
---|---|---|
$string | string | string the string to be translated |
$fromCharset | string | fromCharset the charset the string is currently in |
$toCharset | string | toCharset the charset to translate into (defaults to UTF-8) |
$forceIconv | bool | forceIconv force using the iconv library instead of mb_string |
Type | Description |
---|---|
string | the translated string |
translateCharsetMIME(
$string, $fromCharset, $toCharset
=
'UTF-8', $encoding
=
"Q"
)
:
void
translates a character set from one to another, and the into MIME-header friendly format
Name | Type | Description |
---|---|---|
$string | ||
$fromCharset | ||
$toCharset | ||
$encoding |
translateForEmail(
mixed $var
)
:
mixed
translates the passed variable for email sending (export)
Name | Type | Description |
---|---|---|
$var | mixed | the var (array or string) to translate |
Type | Description |
---|---|
mixed | the translated variable |