BasicTranslator
BasicTranslator defines some base functions for all translators.
Synopsis
Section titled “Synopsis”abstract class BasicTranslator implements ITranslator, ResetInterface
| Implements | ITranslator, ResetInterface |
| Since | 1.0.0 |
| Source | Translation/BasicTranslator.php |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$context | mixed | protected. |
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): mixed | This method gets called by the translation manager when the default locale has been changed. |
reset(): void | Reset per-request state for worker compatibility. |
getContext()
Section titled “getContext()”final public function getContext(): ?Context
Retrieve the current application context.
Returns ?Context — The current Context instance.
initialize()
Section titled “initialize()”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()”public function localeChanged(QuioteLocale $newLocale): mixed
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. |
Returns mixed
reset()
Section titled “reset()”public function reset(): void
Reset per-request state for worker compatibility.
Context is set once at initialize() time and nothing re-initializes a translator between requests, so it is deliberately left alone here; subclasses override this to clear whatever locale-derived state they hold.
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
translate() | ITranslator | Translates a message into the defined language. |