I am trying to translate a string inside a placeholder in a twig (timber) template. But I cannot detect the string in WPML string translation.

<input type="text" id="s" name="s" value="" placeholder="{{ __('Search', 'textdomain') }}">
  • I'd guess WPML scans your code for potential translations and isn't picking this up then? Maybe try adding a reference to that translation somewhere in PHP code and see if that helps. And this is possibly a bug or enhancement report for WPML.
    – Rup
    May 18 '20 at 11:52
  • it is working fine with php code, just the strings inside twig template are not working
    – MMK
    May 18 '20 at 13:54

I managed to assign a variable to context.

$context = Timber::get_context();
$context['search_placeholder'] = __("Suche","pixel_framework");


inside twig

<input type="text" id="s" name="s" value="" placeholder=" {{search_placeholder}}">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.