Class Translator
Provides missing message behavior for CakePHP internal message formats.
Constants summary
-
string
PLURAL_PREFIX'p:'
Properties 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
Method Detail
__construct() public
__construct(mixed $locale, \Aura\Intl\Package $package, \Aura\Intl\FormatterInterface $formatter, \Aura\Intl\TranslatorInterface $fallback)
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
$fallback optional A fallback translator.
getMessage() protected
getMessage(mixed $key)
Gets the message translation by its key.
Parameters
-
string
$key The message key.
Returns
mixed
The message translation string, or false if not found.
getPackage() public
getPackage()
An object of type Package
Returns
\Aura\Intl\Package
resolveContext() protected
resolveContext(string $key, array $message, array $vars)
Resolve a message's context structure.
Parameters
-
string
$key The message key being handled.
-
array
$message The message content.
-
array
$vars The variables containing the
_context
key.
Returns
string|array
translate() public
translate(mixed $key, array $tokensValues)
Translates the message formatting any placeholders
Parameters
-
string
$key The message key.
-
array
$tokensValues optional Token values to interpolate into the message.
Returns
string
The translated message with tokens replaced.
Property Detail
$fallback protected
A fallback translator.
Type
\Aura\Intl\TranslatorInterface
$formatter protected
The formatter to use when translating messages.
Type
\Aura\Intl\FormatterInterface
$locale protected
The locale being used for translations.
Type
string
$package protected
The Package containing keys and translations.
Type
\Aura\Intl\Package
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.I18n.Translator.html