lithium\g11n\Message::aliases()
Returns an array containing named closures which are aliases for translate()
.
They can be embedded as content filters in the template layer using a filter for
Media::_handle()
or be used in other places where needed.
Usage:
$t('bike');
$tn('bike', 'bikes', 3);
Using in a method:
public function index() {
extract(Message::aliases());
$notice = $t('look');
}
Returns
arrayNamed aliases ('t'
and 'tn'
) for translation functions.
Source
public static function aliases() {
$t = function($message, array $options = []) {
return Message::translate($message, $options + ['default' => $message]);
};
$tn = function($message1, $message2, $count, array $options = []) {
return Message::translate($message1, $options + compact('count') + [
'default' => $count === 1 ? $message1 : $message2
]);
};
return compact('t', 'tn');
}