\Cake\I18nTranslator

Provides missing message behavior for CakePHP internal message formats.

Summary

Methods
Properties
Constants
__construct()
translate()
getPackage()
No public properties found
PLURAL_PREFIX
getMessage()
resolveContext()
$fallback
$formatter
$locale
$package
N/A
No private methods found
No private properties found
N/A

Constants

PLURAL_PREFIX

PLURAL_PREFIX = 'p:'

Properties

$locale

$locale : string

The locale being used for translations.

Type

string

$package

$package : \Aura\Intl\Package

The Package containing keys and translations.

Type

\Aura\Intl\Package

Methods

__construct()

__construct(string  $locale, \Aura\Intl\Package  $package, \Aura\Intl\FormatterInterface  $formatter, \Aura\Intl\TranslatorInterface  $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 $fallback

A fallback translator.

translate()

translate(string  $key, array  $tokensValues = array()) : string

Translates the message formatting any placeholders

Parameters

string $key

The message key.

array $tokensValues

Token values to interpolate into the message.

Returns

string —

The translated message with tokens replaced.

getPackage()

getPackage() : \Aura\Intl\Package

An object of type Package

Returns

\Aura\Intl\Package

getMessage()

getMessage(string  $key) : mixed

Gets the message translation by its key.

Parameters

string $key

The message key.

Returns

mixed —

The message translation string, or false if not found.

resolveContext()

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