Methods
-
getFirstDay
Returns the number of day which is used as the beginning of the week in the country corresponding to the specified locale.
-
getInfo
Returns locale parameters.
-
format
Returns a number formatted according to the specified locale.
-
getAll
Returns information about all available locales.
-
fromArray
Returns the value corresponding to the specified locale from an array.
-
transliterate
Returns a transliterated value of a text string according to the specified locale.
public static function getFirstDay ($locale = null)
Returns the number of day which is used as the beginning of the week in the country corresponding to the specified locale.
Parameters
-
$locale
Locale identifier. If no value is specified then the current locale is used.
Example
waLocale::getFirstDay('en_US')
Result
7
public static function getInfo ($locale)
Returns locale parameters.
Parameters
-
$locale
Locale identifier.
Example
waLocale::getInfo('en_US')
Result
[ 'iso3' => 'usa', 'name' => 'English', 'region' => 'USA', 'english_name' => 'English', 'english_region' => 'USA', 'date_formats' => [ 'humandate' => 'F j, Y', 'date' => 'm/d/Y', 'dtime' => 'd/m H:i', 'datetime' => 'm/d/Y H:i', 'fulldatetime' => 'm/d/Y H:i:s', ], 'decimal_point' => '.', 'frac_digits' => '2', 'thousands_sep' => ',', 'first_day' => 7, 'amount_in_words' => [ 'delim' => [ 10 => '-', 100 => ' and ', ], ], 'currency' => 'USD', ]
public static function format ($n, $decimals = null, $locale = null)
Returns a number formatted according to the specified locale.
Parameters
-
$n
The number which needs to be formatted.
-
$decimals
The number of digits after decimal separator which must remain in the formatted number. If an original number contains more digits after decimal separator then the number is rounded to the specified number of digits.
-
$locale
Locale identifier.
Example
waLocale::format(123456.7890, 2, 'en_US')
Result
123,456.79
public static function getAll ($type = false, $enabled_only = true)
Returns information about all available locales.
Parameters
-
$type
Type of values which must be returned:
- 'all' or
true
: return an associative array of locale parameters. - 'name_region': return an associative array with locale identifiers as keys whose values are strings written by pattern “Language name (country name)”.
- 'name': return an associative array with locale identifiers as keys whose values are strings written by pattern “Language name”.
false
: return a zero-based array of locale identifiers.
- 'all' or
-
$enabled_only
Flag denoting that the method must return information only about locales listed in configuration file
wa-config/locale.php
. Otherwise it returns information about all locales described in files in thewa-system/locale/data/
directory.
Example
waLocale::getAll(false)
Result
[ 'en_US', 'de_DE', ]
Example
waLocale::getAll('name_region')
Result
[ 'en_US' => 'English (USA)', 'de_DE => 'Deutsch (Deutschland)', ]
public static function fromArray ($arr, $locale = null)
Returns the value corresponding to the specified locale from an array.
Parameters
-
$arr
Array whose keys are locale identifiers.
-
$locale
Locale identifier. If no value is specified then the current locale is used.
Example
waLocale::fromArray([ 'en_US' => 'English', 'de_DE' => 'Deutsch', ], 'en_US)
Result
English
public static function transliterate ($value, $locale = null)
Returns a transliterated value of a text string according to the specified locale. Transliteration is performed if the locale information contains a letter correspondence table in the translit_table parameter.
Parameters
-
$value
Text string which must be transliterated.
-
$locale
Locale identifier. If no value is specified then the current locale is used.
Example
waLocale::transliterate('привет', 'ru_RU')
Result
privet