Timber & WPML String Translation

Hi, I use Timber and how it was as simple as

_e('string', 'theme') 

to translate lines with WPML doesn't seem to work on Timber about any idea on how to translate lines?

I tried the following and nothing works

{{ _e('string') }} & {{ _('string') }}

{{ _e('string', 'theme') }}

{{ function("icl_translate", 'theme', 'string_identifier', 'string) }}

{{ dump(ICL_LANGUAGE_CODE) }} // Doesn't return anything, so not an option either 

Thank!

+4
source share
2 answers

Yes, I use this:

{{ __('All items', 'theme') }}

And it works great.

+2
source

I just did a quick test and was able to get this to work.

Create a file for transfer "thingy" ==> "foobar"to en_US.moand en_US.poin wp-content/themes/mytheme/languagesthere ...

single.php

$lang_dir = get_stylesheet_directory().'/languages';
load_theme_textdomain('mytheme', $lang_dir);
Timber::render("single.twig");

single.twig

I like {{ __('thingy', 'mytheme') }}

Output

I like foobar

, , . , WPML native translate stuff

0

Source: https://habr.com/ru/post/1670297/


All Articles