Drupal 8, the t() function and the Twig templates

Since Drupal 8 utilizes Twig templates, we cannot make a string translatable with the use of the t() function.

The solution to this problem is the Twig {% trans %} tag. This tag exposes the included string to the translation layer of Drupal 8.


{% trans %} This string will be avaiable for translation at the "User interface translation" of Drupal 8. {% endtrans %}

Filters can also be used with the {% trans %} tag, even though some filters may not work properly. In that case, you may have to create a variable outside the {% trans %} tag.