5

Hi I'm using Timber and what it used to be as simple as

_e('string', 'theme') 

to translate strings with WPML, seems to not been working on Timber any idea on how to translate strings?

I have tried the following and nothing is working

{{ _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 

Thanks!

Mario Sanchez Maselli
  • 1,021
  • 1
  • 12
  • 25

2 Answers2

5

Yes I use this;

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

And it's working perfectly.

Veve
  • 6,643
  • 5
  • 39
  • 58
colin
  • 425
  • 2
  • 5
  • 17
0

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

Created files with a translation for "thingy" ==> "foobar" in en_US.mo and en_US.po in wp-content/themes/mytheme/languages from there...

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

Try replicating that to see if it works. At least at that point we can isolate things to WPML versus native translate stuff

Jared
  • 1,724
  • 12
  • 16