interface Locales (View source)

Locales data source

Methods

public
array
getCountries()

Get all country codes and names

public
array
getLanguages()

Get all language codes and names

public
array
getLocales()

Get all locale codes and names

public
string
countryName(string $code)

Get name of country by code

public
string
languageName(string $code)

Get language name for this language or locale code

public
string
localeName(string $locale)

Get name of locale

public
string
countryFromLocale(string $locale)

Returns the country code / suffix on any locale

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

public
string
langFromLocale(string $locale)

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

public
bool
validate(string $locale)

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

public
string
scriptDirection(string $locale = null)

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

Details

array getCountries()

Get all country codes and names

Return Value

array

Map of country code => name

array getLanguages()

Get all language codes and names

Return Value

array

Map of language code => name

array getLocales()

Get all locale codes and names

Return Value

array

Map of locale code => name

string countryName(string $code)

Get name of country by code

Parameters

string $code

ISO 3166-1 country code

Return Value

string

string languageName(string $code)

Get language name for this language or locale code

Parameters

string $code

Return Value

string

string localeName(string $locale)

Get name of locale

Parameters

string $locale

Return Value

string

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"

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

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"

bool validate(string $locale)

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

Parameters

string $locale

Return Value

bool

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/