Content in Twig templates can translate content either in small sets by using the t or trans filter, or the {% trans %} block. For instance, you can run text through the translate function using either of the following:
{{ 'Hello world' | t }}
{{ 'Hello world' | trans }}
Placing output within a {% trans %} block runs text through the translation function, including handling variables. For example:
{% trans %}
Submitted by {{ author.username }} on {{ node.created }}
{% endtrans %}
This is the same as running t('Submitted by @username on @created') and passing the appropriate variables. The default variable handling is to escape the values, but you are also able to avoid this escaping or wrapping it in an <em> tag by using filters. For example:
{% trans %}
Submitted by {{ author.username | passthrough }} on {{ node.created | passthrough }}
{% endtrans %}
This is the same as running t('Submitted by !username on !created'). Similarly:
{% trans %}
Submitted by {{ author.username | placeholder }} on {{ node.created | placeholder }}
{% endtrans %}
This is the same as running t('Submitted by %username on %created').