{# Test trans tag with string argument. #}
{% trans 'Hello sun.' %}
{# Test trans tag with string argument and context #}
{% trans 'Hello sun.' with {'context': 'Lolspeak'} %}
{# Test trans filter. #}
{{ 'Hello Earth.'|trans }}
{# Test trans tag with text content. #}
{% trans %} Hello moon. {% endtrans %}
{# Test trans/plural tag where count = 1. #}
{% set count = 1 %} {% trans %} Hello star. {% plural count %} Hello {{ count }} stars. {% endtrans %}
{# Test trans/plural tag where count = 2. #}
{% set count = 2 %} {% trans %} Hello star. {% plural count %} Hello {{ count }} stars. {% endtrans %}
{# Test trans tag with different filters applied to tokens. #} {% set string = '&"<>' %}
{% trans %} Escaped: {{ string }} {% endtrans %}
{% trans %} Placeholder: {{ string|placeholder }} {% endtrans %}
{# Test trans tag with complex tokens. #} {% set token = {'name': 'complex token', 'numbers': '12345', 'bad_text': '&"<>' } %} {% set count = token|length %}
{% trans %} This {{ token.name }} has a length of: {{ count }}. It contains: {{ token.numbers|placeholder }} and {{ token.bad_text }}. {% endtrans %}
{# Test trans tag but with a context only msgid. #}
{% trans %} I have context. {% endtrans %}
{# Test trans tag with context. #}
{% trans with {'context': 'Lolspeak'} %} I have context. {% endtrans %}
{# Test trans tag with a specified language. #}
{% trans with {'langcode': 'zz'} %} Hello new text. {% endtrans %}
{# Test trans tag with context and a specified language. #}
{% trans with {'context': 'Lolspeak', 'langcode': 'zz'} %} Hello new text. {% endtrans %}
{# Tests that https://www.drupal.org/node/2489024 doesn't happen without twig debug. #}
{% trans %} Number I never remember: ' . print(pi()) . ' {% endtrans %}