Skip to content

TranslationDefinitions

What the compiled translation configuration declares, as data.

The compiled form used to be statements included inside TranslationManager::initialize(), assigning into its properties and calling $this->getContext() on it. It is a declaration now, for the same reasons the compiled factories, databases and output_types configurations are — see FactoryDefinitions.

The parsed locale identifiers are precomputed at compile time and carried here, which is why identifierData is part of the declared shape rather than something the manager derives.

final readonly class TranslationDefinitions

Since4.0.0
SourceTranslation/TranslationDefinitions.php
PropertyTypeDescription
$defaultDomainstringreadonly.
$defaultLocale?``stringreadonly.
$defaultTimeZone?``stringreadonly.
$localesarrayreadonly.
$translatorsarrayreadonly.

public function __construct(string $defaultDomain, ?string $defaultLocale, ?string $defaultTimeZone, array<string, array{identifier: string, identifierData: array{language: ?string, script: ?string, territory: ?string, variant: ?string, options: array<string, string>, locale_str: ?string, option_str: ?string}, parameters: array<string, mixed>}> $locales, array<string, array<string, array{class: class-string<ITranslator>, parameters: array<string, mixed>, filters: array<int, callable>}>> $translators): mixed

Keyed by domain, then by type (‘msg’, ‘num’, ‘cur’, ‘date’).

ParameterTypeDescription
$defaultDomainstringThe domain used when a caller names none.
$defaultLocale?``stringThe locale identifier to start in. Null is legal here and rejected later by the manager, which has a better message for it than this class could: translation is configured but unusable without one.
$defaultTimeZone?``stringNull means “fall back to PHP’s default”.
$localesarray``<``string``, ``array{identifier: string, identifierData: array{language: ?string, script: ?string, territory: ?string, variant: ?string, options: array<string, string>, locale_str: ?string, option_str: ?string}, parameters: array<string, mixed>}``>Keyed by locale identifier, in declaration order. The parsed identifier is precomputed at compile time by QuioteLocale::parseLocaleIdentifier().
$translatorsarray``<``string``, ``array``<``string``, ``array{class: class-string<ITranslator>, parameters: array<string, mixed>, filters: array<int, callable>}``>``>Keyed by domain, then by type (‘msg’, ‘num’, ‘cur’, ‘date’).

Returns mixed

MethodDescription
fromCompiled(mixed $compiled, string $source = 'the compiled translation cache'): TranslationDefinitionsRead a compiled declaration, rejecting anything malformed.

public static function fromCompiled(mixed $compiled, string $source = 'the compiled translation cache'): TranslationDefinitions

Read a compiled declaration, rejecting anything malformed.

Whatever the compiled file returned.

ParameterTypeDescription
$compiledmixedWhatever the compiled file returned.
$sourcestring

Returns TranslationDefinitions

ThrowsWhen
ConfigurationExceptionWhen $compiled is not a declaration this version understands — most likely a cache compiled by an earlier one.