Symfony - Translate variable value
Translating a label with variable content is trivial with twig. Translating variable values on the other hand isn't that obvious. So here area a few examples how to do so.
Translate value in twig template:
{{ value|trans() }}
Translate with additional key in front of it like for example category.*
:
{{ ('category.' ~ value)|trans() }}
Translate with additional key in front of it and with a special domain:
{{ ('category.' ~ value)|trans({}, "domain") }}