ITranslator
ITranslator defines the interface for different translator implementations (like gettext, XLIFF, …)
Synopsis
Section titled “Synopsis”interface ITranslator
| Implemented by | BasicTranslator, CurrencyFormatter, DateFormatter, QuioteNumberFormatter |
| Since | 1.0.0 |
| Source | Translation/ITranslator.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getContext(): ?Context | Retrieve the current application context. |
initialize(Context $context, array<string, mixed> $parameters = []): void | Initialize this Translator. |
localeChanged(QuioteLocale $newLocale): void | This method gets called by the translation manager when the default locale has been changed. |
translate(mixed $message, string $domain, ?QuioteLocale $locale = null): string | Translates a message into the defined language. |
getContext()
Section titled “getContext()”abstract public function getContext(): ?Context
Retrieve the current application context.
Returns ?Context — The current Context instance.
initialize()
Section titled “initialize()”abstract public function initialize(Context $context, array<string, mixed> $parameters = []): void
Initialize this Translator.
An associative array of initialization parameters
| Parameter | Type | Description |
|---|---|---|
$context | Context | The current application context. |
$parameters | array``<``string``, ``mixed``> | An associative array of initialization parameters |
localeChanged()
Section titled “localeChanged()”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.
| Parameter | Type | Description |
|---|---|---|
$newLocale | QuioteLocale | The new default locale. |
translate()
Section titled “translate()”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.
| Parameter | Type | Description |
|---|---|---|
$message | mixed | The message to be translated. |
$domain | string | The domain of the message. |
$locale | ?QuioteLocale | The locale to which the message should be translated. |
Returns string — The translated message.