class Locale (View source)

Constants

ACTUAL_LOCALE

This is locale the data actually comes from.

VALID_LOCALE

This is the most specific locale supported by ICU.

DEFAULT_LOCALE

Used as locale parameter with the methods of the various locale affected classes, such as NumberFormatter. This constant would make the methods to use default locale.

LANG_TAG

Language subtag

EXTLANG_TAG

Extended language subtag

SCRIPT_TAG

Script subtag

REGION_TAG

Region subtag

VARIANT_TAG

Variant subtag

GRANDFATHERED_LANG_TAG

Grandfathered Language subtag

PRIVATE_TAG

Private subtag

Methods

static string
getDefault()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the default locale value from the INTL global 'default_locale'

static bool
setDefault(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
sets the default runtime locale

static string|null
getPrimaryLanguage(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the primary language for the input locale

static string|null
getScript(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the script for the input locale

static string|null
getRegion(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the region for the input locale

static array|false|null
getKeywords(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the keywords for the input locale

static string|false
getDisplayScript(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for script of the input locale

static string|false
getDisplayRegion(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for region of the input locale

static string|false
getDisplayName(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for the input locale

static string|false
getDisplayLanguage(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for language of the inputlocale

static string|false
getDisplayVariant(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for variants of the input locale

static string|false
composeLocale(array $subtags)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns a correctly ordered and delimited locale ID

static array|null
parseLocale(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns a key-value array of locale ID subtag elements.

static array|null
getAllVariants(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the variants for the input locale

static bool|null
filterMatches(string $languageTag, string $locale, bool $canonicalize = false)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Checks if a language tag filter matches with locale

static string|null
lookup(array $languageTag, string $locale, bool $canonicalize = false, string $defaultLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Searches the language tag list for the best match to the language

static string|null
canonicalize(string $locale)

No description

static string|false
acceptFromHttp(string $header)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Tries to find out best available locale based on HTTP "Accept-Language" header

Details

static string getDefault()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the default locale value from the INTL global 'default_locale'

Return Value

string

The current runtime locale

static bool setDefault(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
sets the default runtime locale

Parameters

string $locale

Is a BCP 47 compliant language tag containing the

Return Value

bool

TRUE on success or FALSE on failure.

static string|null getPrimaryLanguage(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the primary language for the input locale

Parameters

string $locale

The locale to extract the primary language code from

Return Value

string|null

The language code associated with the language or NULL in case of error.

static string|null getScript(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the script for the input locale

Parameters

string $locale

The locale to extract the script code from

Return Value

string|null

The script subtag for the locale or NULL if not present

static string|null getRegion(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the region for the input locale

Parameters

string $locale

The locale to extract the region code from

Return Value

string|null

The region subtag for the locale or NULL if not present

static array|false|null getKeywords(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the keywords for the input locale

Parameters

string $locale

The locale to extract the keywords from

Return Value

array|false|null

Associative array containing the keyword-value pairs for this locale

static string|false getDisplayScript(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for script of the input locale

Parameters

string $locale

The locale to return a display script for

string $displayLocale

Optional format locale to use to display the script name

Return Value

string|false

Display name of the script for the $locale in the format appropriate for $in_locale.

static string|false getDisplayRegion(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for region of the input locale

Parameters

string $locale

The locale to return a display region for.

string $displayLocale

Optional format locale to use to display the region name

Return Value

string|false

display name of the region for the $locale in the format appropriate for $in_locale.

static string|false getDisplayName(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for the input locale

Parameters

string $locale

The locale to return a display name for.

string $displayLocale

optional format locale

Return Value

string|false

Display name of the locale in the format appropriate for $in_locale.

static string|false getDisplayLanguage(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for language of the inputlocale

Parameters

string $locale

The locale to return a display language for

string $displayLocale

Optional format locale to use to display the language name

Return Value

string|false

display name of the language for the $locale in the format appropriate for $in_locale.

static string|false getDisplayVariant(string $locale, string $displayLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns an appropriately localized display name for variants of the input locale

Parameters

string $locale

The locale to return a display variant for

string $displayLocale

Optional format locale to use to display the variant name

Return Value

string|false

Display name of the variant for the $locale in the format appropriate for $in_locale.

static string|false composeLocale(array $subtags)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns a correctly ordered and delimited locale ID

Parameters

array $subtags

an array containing a list of key-value pairs, where the keys identify the particular locale ID subtags, and the values are the associated subtag values.

The 'variant' and 'private' subtags can take maximum 15 values whereas 'extlang' can take maximum 3 values.e.g. Variants are allowed with the suffix ranging from 0-14. Hence the keys for the input array can be variant0, variant1, ...,variant14. In the returned locale id, the subtag is ordered by suffix resulting in variant0 followed by variant1 followed by variant2 and so on.

The 'variant', 'private' and 'extlang' multiple values can be specified both as array under specific key (e.g. 'variant') and as multiple numbered keys (e.g. 'variant0', 'variant1', etc.).

Return Value

string|false

The corresponding locale identifier.

static array|null parseLocale(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Returns a key-value array of locale ID subtag elements.

Parameters

string $locale

The locale to extract the subtag array from. Note: The 'variant' and 'private' subtags can take maximum 15 values whereas 'extlang' can take maximum 3 values.

Return Value

array|null

an array containing a list of key-value pairs, where the keys identify the particular locale ID subtags, and the values are the associated subtag values. The array will be ordered as the locale id subtags e.g. in the locale id if variants are '-varX-varY-varZ' then the returned array will have variant0=>varX , variant1=>varY , variant2=>varZ

static array|null getAllVariants(string $locale)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Gets the variants for the input locale

Parameters

string $locale

The locale to extract the variants from

Return Value

array|null

The array containing the list of all variants subtag for the locale or NULL if not present

static bool|null filterMatches(string $languageTag, string $locale, bool $canonicalize = false)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Checks if a language tag filter matches with locale

Parameters

string $languageTag

The language tag to check

string $locale

The language range to check against

bool $canonicalize

If true, the arguments will be converted to canonical form before matching.

Return Value

bool|null

TRUE if $locale matches $langtag FALSE otherwise.

static string|null lookup(array $languageTag, string $locale, bool $canonicalize = false, string $defaultLocale = null)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Searches the language tag list for the best match to the language

Parameters

array $languageTag

An array containing a list of language tags to compare to locale. Maximum 100 items allowed.

string $locale

The locale to use as the language range when matching.

bool $canonicalize

If true, the arguments will be converted to canonical form before matching.

string $defaultLocale

The locale to use if no match is found.

Return Value

string|null

The closest matching language tag or default value.

static string|null canonicalize(string $locale)

No description

Parameters

string $locale

Return Value

string|null

static string|false acceptFromHttp(string $header)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Tries to find out best available locale based on HTTP "Accept-Language" header

Parameters

string $header

The string containing the "Accept-Language" header according to format in RFC 2616.

Return Value

string|false

The corresponding locale identifier.