class Locale (View source)

Represents a locale

Objects of this kind conveniently represent locales usually described by locale identifiers such as de_DE, en_Latin_US etc. The locale identifiers used are defined in the Unicode Technical Standard #35 (Unicode Locale Data Markup Language).

Using this class asserts the validity of the used locale and provides you with some useful methods for getting more information about it.

Please note that this class represents locale identifier with valid syntax, but it does not assures that represented locale is available (installed) in current Flow installation. In order to check that, various methods of \Neos\Flow\I18n\Service class can be used.

Constants

PATTERN_MATCH_LOCALEIDENTIFIER

Simplified pattern which matches (most) locale identifiers

Properties

protected string $language

The language identifier - a BCP47, ISO 639-3 or 639-5 code Like the standard says, we use "mul" to label multilanguage content

protected string $script

The script identifier - an ISO 15924 code according to BCP47

protected string $region

The region identifier - an ISO 3166-1-alpha-2 code or a UN M.49 three digit code Note: We use "ZZ" for "unknown region" or "global"

protected string $variant

The optional variant identifier - one of the registered registered variants according to BCP47

Methods

__construct(string $localeIdentifier)

Constructs this locale object

string
getLanguage()

Returns the language defined in this locale

string
getScript()

Returns the script defined in this locale

string
getRegion()

Returns the region defined in this locale

string
getVariant()

Returns the variant defined in this locale

string
__toString()

Returns the string identifier of this locale

Details

__construct(string $localeIdentifier)

Constructs this locale object

Parameters

string $localeIdentifier

A valid locale identifier according to UTS#35

Exceptions

InvalidArgumentException
InvalidLocaleIdentifierException

string getLanguage()

Returns the language defined in this locale

Return Value

string

The language identifier

string getScript()

Returns the script defined in this locale

Return Value

string

The script identifier

string getRegion()

Returns the region defined in this locale

Return Value

string

The region identifier

string getVariant()

Returns the variant defined in this locale

Return Value

string

The variant identifier

string __toString()

Returns the string identifier of this locale

Return Value

string

The locale identifier (tag)