Drupal - How do I translate strings in Twig templates?

You need to visit the page in a language that is not English to have them picked up. That should be enough.


Use the t filter:

{{ 'translate me'|t }}

https://www.drupal.org/docs/8/theming/twig/filters-modifying-variables-in-twig-templates


You can use the {% trans %} Twig tag, available in Drupal 8:

{% trans %}
  Submitted by {{ author.username }} on {{ node.created }}
{% endtrans %}

See the following link for more details: http://getlevelten.com/blog/mark-carver/drupal-8-twig-templates-and-translations

Tags:

8

I18N L10N