interface Locales

Locales data source

Methods

array
getCountries()

Get all country codes and names

array
getLanguages()

Get all language codes and names

array
getLocales()

Get all locale codes and names

string
countryName(string $code)

Get name of country by code

string
languageName(string $code)

Get language name for this language or locale code

string
localeName(string $locale)

Get name of locale

string
countryFromLocale(string $locale)

Returns the country code / suffix on any locale

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

bool
validate(string $locale)

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

string
scriptDirection(string $locale = null)

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

Details

at line 15
array getCountries()

Get all country codes and names

Return Value

array Map of country code => name

at line 22
array getLanguages()

Get all language codes and names

Return Value

array Map of language code => name

at line 29
array getLocales()

Get all locale codes and names

Return Value

array Map of locale code => name

at line 37
string countryName(string $code)

Get name of country by code

Parameters

string $code ISO 3166-1 country code

Return Value

string

at line 45
string languageName(string $code)

Get language name for this language or locale code

Parameters

string $code

Return Value

string

at line 53
string localeName(string $locale)

Get name of locale

Parameters

string $locale

Return Value

string

at line 61
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 74
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 83
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 91
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 100
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/