Skip to content

BasicTranslator

BasicTranslator defines some base functions for all translators.

abstract class BasicTranslator implements ITranslator, ResetInterface

ImplementsITranslator, ResetInterface
Since1.0.0
SourceTranslation/BasicTranslator.php
PropertyTypeDescription
$contextmixedprotected.
MethodDescription
getContext(): ?ContextRetrieve the current application context.
initialize(Context $context, array<string, mixed> $parameters = []): voidInitialize this Translator.
localeChanged(QuioteLocale $newLocale): mixedThis method gets called by the translation manager when the default locale has been changed.
reset(): voidReset per-request state for worker compatibility.

final public function getContext(): ?Context

Retrieve the current application context.

Returns ?Context — The current Context instance.

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

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.

ParameterTypeDescription
$newLocaleQuioteLocaleThe new default locale.

Returns mixed

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.

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

MethodDeclared inDescription
translate()ITranslatorTranslates a message into the defined language.