IntlLocales
class IntlLocales implements Locales, Resettable (View source)
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
A class that can be instantiated or replaced via DI
Provides extensions to this object to integrate it with standard config API methods.
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 | ||
countries | array | Standard list of countries |
|
cache_locales | array | Cache of localised locales, keyed by locale localised in |
|
cache_languages | array | Cache of localised languages, keyed by locale localised in |
|
cache_countries | array | Cache of localised countries, keyed by locale localised in |
Properties
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
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".
Validates a "long" locale format (e.g. "en_US") by checking it against $locales.
Details
static Injectable
create(mixed ...$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::class); $list = SiteTree::get();
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).
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
stat(string $name)
deprecated
deprecated
Get inherited config value
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
$this
set_stat(string $name, mixed $value)
deprecated
deprecated
Update the config value for a given property
__construct()
No description
string
scriptDirection(string $locale = null)
Returns the script direction in format compatible with the HTML "dir" attribute.
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.
string
langFromLocale(string $locale)
Returns the "short" language name from a locale, e.g. "en_US" would return "en".
array
getLocales()
Get all locale codes and names
array
getLanguages()
Get all language codes and names
string
localeName(string $locale)
Get name of locale
string
languageName(string $code)
Get language name for this language or locale code
array
getCountries()
Get all country codes and names
string
countryName(string $code)
Get name of country
string
countryFromLocale(string $locale)
Returns the country code / suffix on any locale
bool
validate(string $locale)
Validates a "long" locale format (e.g. "en_US") by checking it against $locales.
static
reset()
Reset the local cache of this object