IntlLocales
class IntlLocales implements Locales, Resettable
Locale metadata
Language codes follow ISO 639-1 (2 letter), unless not present, in which case a locale will be encoded in ISO 639-3 (3 letter). See https://en.wikipedia.org/wiki/ISO_639
Country codes follow ISO 3166-1 alpha-2 (2 letter), unless not present, in which case a country code will be encoded in ISO 3166-1 alpha-3 (3 letter). See https://en.wikipedia.org/wiki/ISO_3166-1
Traits
Config options
locales | array | An exhaustive list of possible locales (code => language and country) | |
languages | array | List of language names | |
text_direction | array | Config for ltr/rtr of specific locales. | |
likely_subtags | array |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
Gets the uninherited value for the given config option
No description
Returns the script direction in format compatible with the HTML "dir" attribute.
Provides you "likely locales" for a given "short" language code. This is a guess, as we can't disambiguate from e.g. "en" to "en_US" - it could also mean "en_UK". Based on the Unicode CLDR project.
Returns the "short" language name from a locale, e.g. "en_US" would return "en".
Get all locale codes and names
Get all language codes and names
Get name of locale
Get language name for this language or locale code
Get all country codes and names
Get name of country
Returns the country code / suffix on any locale
Validates a "long" locale format (e.g. "en_US") by checking it against {@link $locales}.
Reset the local cache of this object
Details
in Injectable at line 26
static Injectable
create(array $args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();
in Injectable at line 43
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
in Configurable at line 20
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in Configurable at line 32
mixed
stat(string $name)
deprecated
deprecated 5.0 Use ->config()->get() instead
Get inherited config value
in Configurable at line 44
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
in Configurable at line 57
$this
set_stat(string $name, mixed $value)
deprecated
deprecated 5.0 Use ->config()->set() instead
Update the config value for a given property
at line 28
__construct()
at line 1373
string
scriptDirection(string $locale = null)
Returns the script direction in format compatible with the HTML "dir" attribute.
at line 1400
string
localeFromLang(string $lang)
Provides you "likely locales" for a given "short" language code. This is a guess, as we can't disambiguate from e.g. "en" to "en_US" - it could also mean "en_UK". Based on the Unicode CLDR project.
at line 1429
string
langFromLocale(string $locale)
Returns the "short" language name from a locale, e.g. "en_US" would return "en".
at line 1446
array
getLocales()
Get all locale codes and names
at line 1478
array
getLanguages()
Get all language codes and names
at line 1504
string
localeName(string $locale)
Get name of locale
at line 1515
string
languageName(string $code)
Get language name for this language or locale code
at line 1532
array
getCountries()
Get all country codes and names
at line 1560
string
countryName(string $code)
Get name of country
at line 1571
string
countryFromLocale(string $locale)
Returns the country code / suffix on any locale
at line 1582
bool
validate(string $locale)
Validates a "long" locale format (e.g. "en_US") by checking it against {@link $locales}.
at line 1612
static
reset()
Reset the local cache of this object