Class Translator
Provides missing message behavior for CakePHP internal message formats.
Property Summary
-
$fallback protected
Aura\Intl\TranslatorInterface
A fallback translator.
-
$formatter protected
Aura\Intl\FormatterInterface
The formatter to use when translating messages.
-
$locale protected
string
The locale being used for translations.
-
$package protected
Aura\Intl\Package
The Package containing keys and translations.
Method Summary
-
__construct() public
Constructor
-
getMessage() protected
Gets the message translation by its key.
-
getPackage() public
An object of type Package
-
resolveContext() protected
Resolve a message's context structure.
-
translate() public
Translates the message formatting any placeholders
Method Detail
__construct() ¶ public
__construct(string $locale, Aura\Intl\Package $package, Aura\Intl\FormatterInterface $formatter, Aura\Intl\TranslatorInterface|null $fallback = null)
Constructor
Parameters
-
string
$locale The locale being used.
-
Aura\Intl\Package
$package The Package containing 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|bool
getPackage() ¶ public
getPackage(): Aura\Intl\Package
An object of type Package
Returns
Aura\Intl\Package
resolveContext() ¶ protected
resolveContext(string $key, string|array $message, array $vars): string
Resolve a message's context structure.
Parameters
-
string
$key The message key being handled.
-
string|array
$message The message content.
-
array
$vars The variables containing the
_context
key.
Returns
string
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
string
Property Detail
$formatter ¶ protected
The formatter to use when translating messages.
Type
Aura\Intl\FormatterInterface