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

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

Methods

static Injectable
create(array $args)

An implementation of the factory method, allows you to create an instance of a class

static Injectable
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

static Config_ForClass
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .

mixed
stat(string $name) 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

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 {@link $locales}.

static 
reset()

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();

Parameters

array $args

Return Value

Injectable

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).

Parameters

string $class Optional classname to create, if the called class should not be used

Return Value

Injectable The singleton instance

in Configurable at line 20
static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .

....).

Return Value

Config_ForClass

in Configurable at line 32
mixed stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

in Configurable at line 44
mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

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

Parameters

string $name
mixed $value

Return Value

$this

at line 28
__construct()

at line 1373
string scriptDirection(string $locale = null)

Returns the script direction in format compatible with the HTML "dir" attribute.

Parameters

string $locale Optional locale incl. region (underscored)

Return Value

string "rtl" or "ltr"

See also

http://www.w3.org/International/tutorials/bidi-xhtml/

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.

Parameters

string $lang Short language code, e.g. "en"

Return Value

string Long locale, e.g. "en_US"

See also

http://www.unicode.org/cldr/data/charts/supplemental/likely_subtags.html

at line 1429
string langFromLocale(string $locale)

Returns the "short" language name from a locale, e.g. "en_US" would return "en".

Parameters

string $locale E.g. "en_US"

Return Value

string Short language code, e.g. "en"

at line 1446
array getLocales()

Get all locale codes and names

Return Value

array Map of locale code => name

at line 1478
array getLanguages()

Get all language codes and names

Return Value

array Map of language code => name

at line 1504
string localeName(string $locale)

Get name of locale

Parameters

string $locale

Return Value

string

at line 1515
string languageName(string $code)

Get language name for this language or locale code

Parameters

string $code

Return Value

string

at line 1532
array getCountries()

Get all country codes and names

Return Value

array Map of country code => name

at line 1560
string countryName(string $code)

Get name of country

Parameters

string $code ISO 3166-1 country code

Return Value

string

at line 1571
string countryFromLocale(string $locale)

Returns the country code / suffix on any locale

Parameters

string $locale E.g. "en_US"

Return Value

string Country code, e.g. "us"

at line 1582
bool validate(string $locale)

Validates a "long" locale format (e.g. "en_US") by checking it against {@link $locales}.

Parameters

string $locale

Return Value

bool

at line 1612
static reset()

Reset the local cache of this object