Skip to content

QuioteLocale

Represents a single locale: its identifier plus the language/territory/ script/variant and the calendar/currency/timezone options carried in the identifier’s ‘@key=value’ suffix.

All CLDR-derived metadata (calendar names, number symbols, display names, …) is served directly from ext/intl by the formatters and the TranslationManager; this class only resolves the identifier and its options.

class QuioteLocale extends ParameterHolder

ExtendsParameterHolder
Since1.0.0
SourceTranslation/QuioteLocale.php
MethodDescription
getCharacterOrientation(): stringWhich way this locale’s text runs: left-to-right or right-to-left.
getContext(): ?ContextRetrieve the current application context.
getCurrencyDisplayName(string $code): ?stringThe name of a currency as this locale writes it: EUR as “Euro” in en, “euro” in fi.
getIdentifier(): ?stringReturns the identifier of this locale
getLocaleCalendar(): ?string
getLocaleCurrency(): ?string
getLocaleLanguage(): ?string
getLocaleScript(): ?string
getLocaleTerritory(): ?string
getLocaleTimeZone(): ?string
getLocaleVariant(): ?string
[`getLookupPath(stringnull
[`getTimeZoneOptionString(DateTimeInterfaceDateTimeZone
initialize(Context $context, array<string, mixed> $parameters = [], string $identifier = null, array<string, mixed> $data = []): voidInitialize this Locale.
parseLocaleIdentifier(string $identifier): array{language: ?string, script: ?string, territory: ?string, variant: ?string, options: array<string, string>, locale_str: ?string, option_str: ?string}Parses a locale identifier and returns its parts.
reset(): voidReturns this locale to its just-constructed state for reuse across requests.

public function getCharacterOrientation(): string

Which way this locale’s text runs: left-to-right or right-to-left.

The answer a template needs to decide dir="rtl", which is the only thing anything has ever asked this for.

Resolved from the locale’s script, because that is what decides direction — and asked of ICU rather than of the identifier, since a bare ar or ur names no script. addLikelySubtags() is how ICU says which script a language is written in by default, so ur resolves through ur_Arab_PK and an explicit az_Latn is taken at its word.

Left-to-right is the answer when the script cannot be determined at all. It is the direction of the overwhelming majority of locales, and a page laid out left to right for a locale nobody could identify is a smaller wrong than one laid out backwards.

Returns stringleft-to-right or right-to-left.

final public function getContext(): ?Context

Retrieve the current application context.

Returns ?Context — The current Context instance.

public function getCurrencyDisplayName(string $code): ?string

The name of a currency as this locale writes it: EUR as “Euro” in en, “euro” in fi.

An ISO 4217 code, e.g. EUR.

ParameterTypeDescription
$codestringAn ISO 4217 code, e.g. EUR.

Returns ?``string — The localized name, or null when this locale’s data does not name the code.

public function getIdentifier(): ?string

Returns the identifier of this locale

Returns ?``string — The identifier.

public function getLocaleCalendar(): ?string

Returns ?``string — The calendar identifier of this locale.

public function getLocaleCurrency(): ?string

Returns ?``string — The currency code of this locale.

public function getLocaleLanguage(): ?string

Returns ?``string — The language of this locale.

public function getLocaleScript(): ?string

Returns ?``string — The script of this locale.

public function getLocaleTerritory(): ?string

Returns ?``string — The territory of this locale.

public function getLocaleTimeZone(): ?string

Returns ?``string — The timezone identifier of this locale.

public function getLocaleVariant(): ?string

Returns ?``string — The variant of this locale.

public static function getLookupPath(string|null|array{language: ?string, script: ?string, territory: ?string, variant: ?string, options: array<string, string>, locale_str: ?string, option_str: ?string} $localeIdentifier): array<int, string>

Returns all file names which need to be considered for the given identifier.

The locale identifier or the result of QuioteLocale::parseLocaleIdentifier. A null identifier is treated as the empty string, which parseLocaleIdentifier rejects as invalid.

ParameterTypeDescription
$localeIdentifier`string“null

Returns array``<``int``, ``string``> — The filenames.

public static function getTimeZoneOptionString(DateTimeInterface|DateTimeZone|string|int $item, string $prefix = '@'): string

Returns the locale option string containing the timezone option set to the timezone of this calendar.

The prefix which will be applied to the timezone option string. Use ’;’ here if you intend to use several locale options and append the result of this method to your locale string.

ParameterTypeDescription
$itemDateTimeInterface`DateTimeZone
$prefixstringThe prefix which will be applied to the timezone option string. Use ’;’ here if you intend to use several locale options and append the result of this method to your locale string.

Returns string — Returns an empty string (NOT containing the $prefix) if $item is invalid or no timezone could be determined

public function initialize(Context $context, array<string, mixed> $parameters = [], string $identifier = null, array<string, mixed> $data = []): void

Initialize this Locale.

The locale data.

ParameterTypeDescription
$contextContextThe current application context.
$parametersarray``<``string``, ``mixed``>An associative array of initialization parameters.
$identifierstringThe identifier of the locale
$dataarray``<``string``, ``mixed``>The locale data.

public static function parseLocaleIdentifier(string $identifier): array{language: ?string, script: ?string, territory: ?string, variant: ?string, options: array<string, string>, locale_str: ?string, option_str: ?string}

Parses a locale identifier and returns its parts.

The locale identifier.

ParameterTypeDescription
$identifierstringThe locale identifier.

Returns array{language: ?string, script: ?string, territory: ?string, variant: ?string, options: array<string, string>, locale_str: ?string, option_str: ?string} — The parts of the identifier

public function reset(): void

Returns this locale to its just-constructed state for reuse across requests.

Drops the context, the loaded locale data, the identifier and the parameters, so a pooled worker re-initializes the locale from scratch rather than serving the previous request’s language.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
removeParameter()ParameterHolderRemove a parameter.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.