Skip to content

ITranslator

ITranslator defines the interface for different translator implementations (like gettext, XLIFF, …)

interface ITranslator

Implemented byBasicTranslator, CurrencyFormatter, DateFormatter, QuioteNumberFormatter
Since1.0.0
SourceTranslation/ITranslator.php
MethodDescription
getContext(): ?ContextRetrieve the current application context.
initialize(Context $context, array<string, mixed> $parameters = []): voidInitialize this Translator.
localeChanged(QuioteLocale $newLocale): voidThis method gets called by the translation manager when the default locale has been changed.
translate(mixed $message, string $domain, ?QuioteLocale $locale = null): stringTranslates a message into the defined language.

abstract public function getContext(): ?Context

Retrieve the current application context.

Returns ?Context — The current Context instance.

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

Initialize this Translator.

An associative array of initialization parameters

ParameterTypeDescription
$contextContextThe current application context.
$parametersarray``<``string``, ``mixed``>An associative array of initialization parameters

abstract public function localeChanged(QuioteLocale $newLocale): void

This method gets called by the translation manager when the default locale has been changed.

The new default locale.

ParameterTypeDescription
$newLocaleQuioteLocaleThe new default locale.

abstract public function translate(mixed $message, string $domain, ?QuioteLocale $locale = null): string

Translates a message into the defined language.

The locale to which the message should be translated.

ParameterTypeDescription
$messagemixedThe message to be translated.
$domainstringThe domain of the message.
$locale?QuioteLocaleThe locale to which the message should be translated.

Returns string — The translated message.