mini\I18n\Translator class

Documentation

Translator class responsible for loading and managing translations

Handles translation file loading, caching, and fallback logic. Automatically creates missing translation entries in the default language files.

Implements TranslatorInterface to allow custom translator implementations.

Inheritance

Implements: mini\I18n\TranslatorInterface

Properties (5)

private mini\Util\PathsRegistry $translationsPaths
private string $defaultLanguage
private array $loadedTranslations
private bool $autoCreateDefaults
private array $pathAliases

Methods (14)

Documentation missing

Add a path alias for translation file resolution

Get current language code from global locale

Translate a Translatable instance using ICU MessageFormatter

Get translation for a specific source text from a specific file

Load translation from a specific language file with alias prefix support

Extract translation from loaded translations array with conditional support

Resolve conditional translation based on variable values using QueryParser

Evaluate a condition string against variable values using QueryParser

Get all translations for a specific language and file with alias prefix support

Ensure default translation exists for a source text with alias prefix support

Get the full path to a translation file with alias prefix support

Format message using ICU MessageFormatter

Determine the alias prefix for a source file based on registered path aliases

Source

src/I18n/Translator.php:18-354