Back to index

php5  5.3.10
Static Public Member Functions | Public Attributes
Locale Class Reference

A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. More...

List of all members.

Static Public Member Functions

static getDefault ()
 Gets the default locale value from the INTL global 'default_locale' At the PHP initilaization (MINIT) this value is set to 'intl.default_locale' value from php.ini if that value exists or from ICU's function uloc_getDefault() Then onwards picks up changes from setDefault() calls also.
static setDefault ($locale)
 sets the default runtime locale to $locale This changes the value of INTL global 'default_locale'
static getPrimaryLanguage ($locale)
 Gets the primary language for the input locale.
static getScript ($locale)
 Gets the script for the input locale.
static getRegion ($locale)
 Gets the region for the input locale.
static getAllVariants ($locale)
 Gets the variants for the input locale.
static getKeywords ($locale)
 Gets the keywords for the input locale.
static getDisplayName ($locale, $in_locale=null)
 Returns an appropriately localized display name for the input locale.
static getDisplayLanguage ($lang, $in_locale=null)
 Returns an appropriately localized display name for language of the input locale.
static getDisplayScript ($script, $in_locale=null)
 Returns an appropriately localized display name for script of the input locale.
static getDisplayRegion ($region, $in_locale=null)
 Returns an appropriately localized display name for region of the input locale.
static getDisplayVariant ($variant, $in_locale=null)
 Returns an appropriately localized display name for variants of the input locale.
static filterMatches ($langtag, $locale, $canonicalize)
 Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm.
static lookup (array $langtag, $locale, $default=null)
 Searchs the items in $langtag for the best match to the language range specified in $locale according to RFC 4647's lookup algorithm.
static composeLocale (array $subtags)
 Returns a correctly ordered and delimited locale ID.
static parseLocale ($locale)
 Returns a key-value array of locale ID subtag elements.

Public Attributes

const DEFAULT_LOCALE = null
 The following static members are used with the getLocale methods of the various locale affected classes, such as numfmt.
const ACTUAL_LOCALE = 'ULOC_ACTUAL_LOCALE'
 identifiers for the actual locale, valid locale WARNING: The values described here are NOT the actual values in PHP code.
const VALID_LOCALE = 'ULOC_VALID_LOCALE'
const LANG_TAG = "language"
 Valid locale tag and subtag values.
const EXTLANG_TAG = "extlang"
const SCRIPT_TAG = "script"
const REGION_TAG = "region"
const VARIANT_TAG = "variant"
const GRANDFATHERED_LANG_TAG = "grandfathered"
const PRIVATE_TAG = "private"

Detailed Description

A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API.

PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use. Locales are identified using RFC 4646 language tags (which use hyphen, not underscore) in addition to the more traditional underscore-using identifiers. Unless otherwise noted the functions in this class are tolerant of both formats.

Examples of identifiers include:

The Locale class (and related procedural functions) are used to interact with locale identifiers--to verify that an ID is well-formed, valid, etc. The extensions used by CLDR in UAX #35 (and inherited by ICU) are valid and used wherever they would be in ICU normally.

Locales cannot be instantiated as objects. All of the functions/methods provided are static.

See also:
http://www.icu-project.org/apiref/icu4c/uloc_8h.html
http://www.unicode.org/reports/tr35/

Definition at line 35 of file locale_api.php.


Member Function Documentation

static Locale::composeLocale ( array $  subtags) [static]

Returns a correctly ordered and delimited locale ID.

Parameters:
array$subtagsan 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.
Returns:
string the corresponding locale identifier.

Definition at line 237 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::filterMatches ( langtag,
locale,
canonicalize 
) [static]

Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm.

Parameters:
string$langtagthe language tag to check
string$localethe language range to check against
bool$canonicalizeCanonicalize parameters?
Returns:
boolean 'true' if $locale matches $langtag 'false' otherwise

Definition at line 212 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getAllVariants ( locale) [static]

Gets the variants for the input locale.

Parameters:
string$localethe locale to extract the variants from
Returns:
array the array containing the list of all variants subtag for the locale or null if not present

Definition at line 132 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getDefault ( ) [static]

Gets the default locale value from the INTL global 'default_locale' At the PHP initilaization (MINIT) this value is set to 'intl.default_locale' value from php.ini if that value exists or from ICU's function uloc_getDefault() Then onwards picks up changes from setDefault() calls also.

Returns:
string the current runtime locale

Definition at line 84 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getDisplayLanguage ( lang,
in_locale = null 
) [static]

Returns an appropriately localized display name for language of the input locale.

Parameters:
string$localethe locale to return a display language for
[string]$in_locale optional format locale to use to display the language name If is 'null' then the default locale is used.
Returns:
string display name of the language for the $locale in the format appropriate for $in_locale.

Definition at line 165 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getDisplayName ( locale,
in_locale = null 
) [static]

Returns an appropriately localized display name for the input locale.

Parameters:
string$localethe locale to return a displayname for
[string]$in_locale optional format locale If is 'null' then the default locale is used.
Returns:
string display name of the locale in the format appropriate for $in_locale.

Definition at line 153 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getDisplayRegion ( region,
in_locale = null 
) [static]

Returns an appropriately localized display name for region of the input locale.

Parameters:
string$localethe locale to return a display region for
[string]$in_locale optional format locale to use to display the region name If is 'null' then the default locale is used.
Returns:
string display name of the region for the $locale in the format appropriate for $in_locale.

Definition at line 188 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getDisplayScript ( script,
in_locale = null 
) [static]

Returns an appropriately localized display name for script of the input locale.

Parameters:
string$localethe locale to return a display script for
[string]$in_locale optional format locale to use to display the script name If is 'null' then the default locale is used.
Returns:
string display name of the script for the $locale in the format appropriate for $in_locale.

Definition at line 176 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getDisplayVariant ( variant,
in_locale = null 
) [static]

Returns an appropriately localized display name for variants of the input locale.

Parameters:
string$localethe locale to return a display variant for
[string]$in_locale optional format locale to use to display the variant name If is 'null' then the default locale is used.
Returns:
string display name of the variant for the $locale in the format appropriate for $in_locale.

Definition at line 200 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getKeywords ( locale) [static]

Gets the keywords for the input locale.

Parameters:
string$localethe locale to extract the keywords from
Returns:
array associative array containing the keyword-value pairs for this locale

Definition at line 141 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getPrimaryLanguage ( locale) [static]

Gets the primary language for the input locale.

Parameters:
string$localethe locale to extract the primary language code from
Returns:
string the language code associated with the language or null in case of error.

Definition at line 104 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getRegion ( locale) [static]

Gets the region for the input locale.

Parameters:
string$localethe locale to extract the region code from
Returns:
string the region subtag for the locale or null if not present

Definition at line 122 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::getScript ( locale) [static]

Gets the script for the input locale.

Parameters:
string$localethe locale to extract the script code from
Returns:
string the script subtag for the locale or null if not present

Definition at line 113 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::lookup ( array $  langtag,
locale,
default = null 
) [static]

Searchs the items in $langtag for the best match to the language range specified in $locale according to RFC 4647's lookup algorithm.

Parameters:
array$langtagan array containing a list of language tags to compare to $locale
string$localethe locale to use as the language range when matching
string$defaultthe locale to use if no match is found
Returns:
string closest matching language tag, $default, or empty string

Definition at line 225 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::parseLocale ( locale) [static]

Returns a key-value array of locale ID subtag elements.

Parameters:
string$localethe locale to extract the subtag array from
Returns:
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.

Definition at line 249 of file locale_api.php.

{}

Here is the caller graph for this function:

static Locale::setDefault ( locale) [static]

sets the default runtime locale to $locale This changes the value of INTL global 'default_locale'

Parameters:
string$localeis a BCP 47 compliant language tag containing the locale identifier. UAX #35 extensions are accepted.
Returns:
boolean 'true' if okay, 'false' if an error

Definition at line 94 of file locale_api.php.

{}

Here is the caller graph for this function:


Member Data Documentation

const Locale::ACTUAL_LOCALE = 'ULOC_ACTUAL_LOCALE'

identifiers for the actual locale, valid locale WARNING: The values described here are NOT the actual values in PHP code.

They are references to the ICU C definitions, so the line const ACTUAL_LOCALE = 'ULOC_ACTUAL_LOCALE'; actually means that Locale::ACTUAL_LOCALE is the same as ULOC_ACTUAL_LOCALE constant in the ICU library.

Definition at line 56 of file locale_api.php.

const Locale::DEFAULT_LOCALE = null

The following static members are used with the getLocale methods of the various locale affected classes, such as numfmt.

Definition at line 45 of file locale_api.php.

const Locale::EXTLANG_TAG = "extlang"

Definition at line 63 of file locale_api.php.

const Locale::GRANDFATHERED_LANG_TAG = "grandfathered"

Definition at line 67 of file locale_api.php.

const Locale::LANG_TAG = "language"

Valid locale tag and subtag values.

Definition at line 62 of file locale_api.php.

const Locale::PRIVATE_TAG = "private"

Definition at line 68 of file locale_api.php.

const Locale::REGION_TAG = "region"

Definition at line 65 of file locale_api.php.

const Locale::SCRIPT_TAG = "script"

Definition at line 64 of file locale_api.php.

const Locale::VALID_LOCALE = 'ULOC_VALID_LOCALE'

Definition at line 57 of file locale_api.php.

const Locale::VARIANT_TAG = "variant"

Definition at line 66 of file locale_api.php.


The documentation for this class was generated from the following file: