a.daniello Posted April 13, 2015 Report Posted April 13, 2015 I'm playing with the great Admin Tools by naja7host and i need to use in my cms pages something to be translated. So i make this simple extension of h2o. 1. create a file called "translate.php" under "vendors/h2o/ext"; 2. add this code to the file <?php class Translate_Tag extends H2o_Node { var $lang_key; function __construct($argstring, $parser, $pos=0) { $this->lang_key = trim($argstring); } function render($context, $stream) { $stream->write(Language::_($this->lang_key, true)); } } h2o::addTag('translate'); 3. load this tag where do you need (for frontend, in "plugins/cms/controllers/main.php" at line 56) adding this code h2o::load('translate'); It's all! So you can add a simple h2o tag as you need, for example {% translate here_write_language_key_or_your_string_also_with_spaces %} Usually, i'm adding my custom text in languages/[lang]/_custom.php. Hope that this can help someone. Blesta Addons, Michael, Abdy and 1 other 4 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.