Twig Filter

The |trans and |transchoice filters translate the value passed in using the applications localization configuration. The localization strings can be loaded by passing the default translation of your string.

{{ 'I love programming.'|trans }};

Replacing parameters in translation strings is possible by passing an array as the first argument. Every parameter is prefixed with a : character.

{{ ':name loves programming.'|trans({ name: 'Jeff' }) }}

The trans_choice function is used to process pluralized values.

{{ 'There is one apple|There are many apples'|transchoice(3) }}

# See Also

On This Page