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') }}">
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI 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 managed to assign a variable to context.
$context = Timber::get_context();
$context['search_placeholder'] = __("Suche","pixel_framework");
Timber::fetch('test.twig',$context);
inside twig
<input type="text" id="s" name="s" value="" placeholder=" {{search_placeholder}}">
.twig
files is not scanned by WPML, only in .php
files. This seems sensible, potentially a locale file could even be created to store all of these and add them to context. e.g. en.php
Jun 16 at 14:25