This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I think translate is missing inside themes.
If I am developing a theme I would like to use translate object with theme related strings under theme folder. This will enable other people to contribute translations as well.
I know there is a translate plugin available and it is ok for translating content. But as far as template development goes I believe there should be availability to include translated strings / images inside template itself.
Last updated
code200.miha said: I think translate is missing inside themes.
What you think is a bit outdated: https://github.com/rainlab/bonjour-theme/blob/master/theme.yaml https://github.com/rainlab/bonjour-theme/blob/master/partials/site/nav.htm#L13
(just no UI & proper documentation yet)
Thanks. I found it a bit later. But still I think theme translations should be supported out of the box like plugins translation work. It is confusing for developers to use one type of translations for plugins and other way with 3rd party plugins for templates.
For those who need a solution without translate plugin :
In layout php file :
function onInit()
{
Lang::addNamespace('theme', 'themes/yourtheme/lang');
App::setLocale('fr'); // set locale you want
}
then in your pages (using this layout), you can use trans('theme::lang.whatever.code'). You must have themes/yourtheme/lang/{locale}/lang.php files (like in plugins).
You can use trans function with twig : {{ trans('theme::lang.code.name') }}
1-5 of 5