Is there a way to pass through a variable to Kohana messages, which can then be picked up by the il8n translation e.g.:
Kohana::message('user', 'greeting')
messages/user.php:
return array
(
'greeting' => __('user.greeting', array(':user' => $name ))
);
i18n/en.php:
return array
(
'greeting' => 'Hello, :user'
);
I grabbed the method of linking the il8n to message from i18n and Error messages in Kohana 3
I don’t have the exact answer you are looking for, but I could suggest a solution if you don’t mind overwriting the current Kohana::message() method. I have done something similar in my own app.
Just create a Kohana.php file in your ‘applications/classes’ with the following code:
Basically the only notable change is the addition of
$replacementsargument andreturn !empty($replacements) ? strtr($message,$replacements) : $message;which replaces the contents of your message with those that are in your replacements array.So you can now do this:
Kohana::message('user', 'greeting', NULL, array(':user' => $name));messages/user.php: