class Locale implements LocaleInterface, LocaleEntityInterface, TreeInterface, JsonSerializable (View source)

Represents a site locale.

Traits

Properties

protected string $msLanguage

The language code.

from  LocaleTrait
protected string $msCountry

The Country/territory code.

from  LocaleTrait
protected int $msNumPlurals

The number of plural rules used in this locale.

from  LocaleTrait
protected string $msPluralRule

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

from  LocaleTrait
protected string $msPluralCases

The plural rule names with examples (using CLDR format).

from  LocaleTrait
protected $siteLocaleID
protected $site
protected $tree
$msIsDefault

Methods

string
getLanguage()

Get the language code.

setLanguage(string $msLanguage)

Set the language code.

string
getCountry()

Get the Country/territory code.

setCountry(string $msCountry)

Set the Country/territory code.

int
getNumPlurals()

Get the number of plural rules used in this locale.

setNumPlurals(int $msNumPlurals)

Set the number of plural rules used in this locale.

string
getPluralRule()

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

setPluralRule(string $msPluralRule)

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

array
getPluralCases()

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

setPluralCases(string $msPluralCases)

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

string
getLocale()

Get the full code of this locale.

string
getLanguageText(string|null $locale = null)

Get the display name of this locale.

getExporter()

Get the object to be used to export this item to aSimpleXMLElement.

int|null
getLocaleID()

Get the locale record identifier.

bool
getIsDefault()

Is this the default locale?

setIsDefault(bool $msIsDefault)

Is this the default locale?

Site|null
getSite()

Get the site associated to this locale.

setSite(Site $site = null)

Set the site associated to this locale.

getSiteTree()

Get the site tree associated to this locale.

setSiteTree(TreeInterface $tree)

Set the site tree associated to this locale.

int|null
getSiteTreeID()

No description

Tree|null
getSiteTreeObject()

No description

jsonSerialize()

No description

Details

string getLanguage()

Get the language code.

Return Value

string

Examples

<code>en</code>

setLanguage(string $msLanguage)

Set the language code.

Parameters

string $msLanguage

Examples

<code>en</code>

string getCountry()

Get the Country/territory code.

Return Value

string

Examples

<code>US</code>

setCountry(string $msCountry)

Set the Country/territory code.

Parameters

string $msCountry

Examples

<code>US</code>

int getNumPlurals()

Get the number of plural rules used in this locale.

Return Value

int

setNumPlurals(int $msNumPlurals)

Set the number of plural rules used in this locale.

Parameters

int $msNumPlurals

string getPluralRule()

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

Return Value

string

Examples

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

setPluralRule(string $msPluralRule)

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

Parameters

string $msPluralRule

Examples

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

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>

setPluralCases(string $msPluralCases)

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

Parameters

string $msPluralCases

Examples

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

string getLocale()

Get the full code of this locale.

Return Value

string

Examples

<code>en_US</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

Locale getExporter()

Get the object to be used to export this item to aSimpleXMLElement.

Return Value

Locale

int|null getLocaleID()

Get the locale record identifier.

Return Value

int|null

See also

LocaleInterface::getLocaleID

bool getIsDefault()

Is this the default locale?

Return Value

bool

setIsDefault(bool $msIsDefault)

Is this the default locale?

Parameters

bool $msIsDefault

Site|null getSite()

Get the site associated to this locale.

Return Value

Site|null

setSite(Site $site = null)

Set the site associated to this locale.

Parameters

Site $site

TreeInterface getSiteTree()

Get the site tree associated to this locale.

Return Value

TreeInterface

setSiteTree(TreeInterface $tree)

Set the site tree associated to this locale.

Parameters

TreeInterface $tree

int|null getSiteTreeID()

No description

Return Value

int|null

See also

TreeInterface::getSiteTreeID

Tree|null getSiteTreeObject()

No description

Return Value

Tree|null

See also

TreeInterface::getSiteTreeObject

jsonSerialize()

No description