trans
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 Winter CMS.' | trans }}
or an example using a language variable:
{{ "acme.demo::lang.string.example" | 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 Winter CMS.' | trans({ name: 'Samuel' }) }}
Pluralization
The transchoice
function is used to process pluralized values.
{{ 'There is one snowflake|There are many snowflakes' | transchoice(7) }}
The second argument can contain the parameters.
{{ '{1} :value minute ago|[2,*] :value minutes ago' | transchoice(5, { value: 5 }) }}
Copyright © 2024 Winter CMS