interface LocaleInterface (View source)

Methods

int|null
getLocaleID()

Get the locale record identifier.

string
getLanguage()

Get the language code.

string
getCountry()

Get the Country/territory code.

string
getLocale()

Get the full code of this locale.

int
getNumPlurals()

Get the number of plural rules used in this locale.

array
getPluralCases()

Get the plural rule names with examples (using CLDR format).

string
getPluralRule()

Get the plural rules definition of this locale (using gettext format).

setNumPlurals(mixed $numPlurals)

Set the number of plural rules used in this locale.

setPluralCases(mixed $numCases)

Set the plural rule names with examples (using CLDR format).

setPluralRule(mixed $pluralRule)

Set the plural rules definition of this locale (using gettext format).

string
getLanguageText(string|null $locale = null)

Get the display name of this locale.

Details

int|null getLocaleID()

Get the locale record identifier.

Return Value

int|null

string getLanguage()

Get the language code.

Return Value

string

Examples

<code>en</code>

string getCountry()

Get the Country/territory code.

Return Value

string

Examples

<code>US</code>

string getLocale()

Get the full code of this locale.

Return Value

string

Examples

<code>en_US</code>

int getNumPlurals()

Get the number of plural rules used in this locale.

Return Value

int

array getPluralCases()

Get the plural rule names with examples (using CLDR format).

Return Value

array

array keys are the CLDR identifiers or the plural rules (zero, one, two, few, many, other), array values are example values

Examples

<pre><code>[
    'one' => '1',
    'other' => '0, 2~16, 100, 1000, 10000, 100000, 1000000, …',
]</code></pre>

string getPluralRule()

Get the plural rules definition of this locale (using gettext format).

Return Value

string

Examples

<code>(n != 1)</code>

setNumPlurals(mixed $numPlurals)

Set the number of plural rules used in this locale.

Parameters

mixed $numPlurals

setPluralCases(mixed $numCases)

Set the plural rule names with examples (using CLDR format).

Parameters

mixed $numCases

Examples

<code>one@1\nother@0, 2~16, 100, 1000, 10000, 100000, 1000000, …</code>

setPluralRule(mixed $pluralRule)

Set the plural rules definition of this locale (using gettext format).

Parameters

mixed $pluralRule

Examples

<code>(n != 1)</code>

string getLanguageText(string|null $locale = null)

Get the display name of this locale.

Parameters

string|null $locale

The locale to be used to localize the locale name

Return Value

string

Examples

<code>getLanguage('en_US')</code> returns the display name of this locale in American English
<code>getLanguage('it_IT')</code> returns the display name of this locale in Italian
<code>getLanguage()</code> returns the display name of this locale in the currently active locale