This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello,
I would like to use localization in my plugin components but I don't know how can I use localization in my default.htm file?
I've made lang folder and specified lang.php files and I tried to use the echo Lang::get('acme.blog::lang.app.name'); in my default.htm file but it did not work...
Could you please help my how could I translate my components?
Thank you!
Easy way is to use Translate plugin and then you can use {{ 'Welcome to our website!'|_ }} this syntax in your partial files like default.htm. If you want to get translations from /lang/en/ folder and lang files use:
public function init()
{
$this->page['word_keywords'] = Lang::get('acme.demo::lang.word.keywords');
}
in default.htm you will output {{ wordkeywords }} ... you can probably run througn array and pass the whole array... I'm working on this now )))
another way if you do not want to depend Translate plugin and want to use lang.php files:
<?= e(trans('acme.demo::lang.word.keywords')) ?> use like this way in your .htm files
Tried using that e(trans()) with PHP tags in an .htm partial... Didn't think it would work, and it didn't.
Have you ever get a chance to take a look at the source codes of the system? Just only one example:
maybe you wrote wrong in partial. For example forgot echoing or not existent lang key? Have you enabled short php syntax? OctoberCMS uses syntaxes in partials <?= e(trans('acme.demo::lang.word.keywords')) ?> or <?php echo e(trans('acme.demo::lang.word.keywords')) ?> for easy use.
So, if you wouldn't think it works anyway, you should search other logical ways which you think it would work..
I was able to translate using {{ 'acme.demo::lang.app.keywords' | trans }} and having my french and english lang.php. But I think this method will only work for the component partials.
lunfel said:
I was able to translate using {{ 'acme.demo::lang.app.keywords' | trans }} and having my french and english lang.php. But I think this method will only work for the component partials.
This did work for me too! Thanks!!!
1-7 of 7