How to use kohana i18n __('translation') within kostache templates?
How to use kohana i18n __(‘translation’) within kostache templates?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Make an custom extension method for Kostache and use it like that.
I use somehting like this in the modules/kostache/classes/kohana/kostache.php file:
You could probably do it a little nicer with PHP 5.3, but this works on all PHP versions
And in the templates, you will do something like:
The nice thing about mustache is that you can use it in almost any language (including js, so you can use same templates for client and server side). Extending with custom methods adds a little complexity, so you will have to implement them in all languages where you use mustache. Luckily it is pretty simple to do it in js since everything is an object.
For example, something like this would work:
Now you can use your extension method on the client as well as server.
Nice, isn’t it 🙂