Class Translator
Provides missing message behavior for CakePHP internal message formats.
Namespace: Cake\I18n
Property Summary
-
$fallback protected
Aura\Intl\TranslatorInterfaceA fallback translator.
-
$formatter protected
Aura\Intl\FormatterInterfaceThe formatter to use when translating messages.
-
$locale protected
stringThe locale being used for translations.
-
$messages protected
arrayThe message keys and translations.
Method Summary
-
__construct() public
Constructor
-
getMessage() protected
Gets the message translation by its key.
-
translate() public
Translates the message formatting any placeholders
Method Detail
__construct() ¶ public
__construct(string $locale, array $messages, Aura\Intl\FormatterInterface $formatter, Aura\Intl\TranslatorInterface|null $fallback = null)
Constructor
Parameters
-
string$locale The locale being used.
-
array$messages The message keys and translations.
-
Aura\Intl\FormatterInterface$formatter A message formatter.
-
Aura\Intl\TranslatorInterface|null$fallback optional A fallback translator.
getMessage() ¶ protected
getMessage(string $key): string|bool
Gets the message translation by its key.
Parameters
-
string$key The message key.
Returns
string|boolThe message translation string, or false if not found.
translate() ¶ public
translate(string $key, array $tokensValues = []): string
Translates the message formatting any placeholders
Parameters
-
string$key The message key.
-
array$tokensValues optional Token values to interpolate into the message.
Returns
stringThe translated message with tokens replaced.
Property Detail
$formatter ¶ protected
The formatter to use when translating messages.
Type
Aura\Intl\FormatterInterface