Locales
interface Locales (View source)
Locales data source
Methods
Get all country codes and names
Get all language codes and names
Get all locale codes and names
Get name of country by code
Get language name for this language or locale code
Get name of locale
Returns the country code / suffix on any locale
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 {@link $locales}.
Returns the script direction in format compatible with the HTML "dir" attribute.
Details
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.