Reputation: 3498
In my translation.yml I have this var:
all.in.EN: All In Great Britain
In my Twig I have something like this:
{% trans %}all.in.{{ countryKey }}{% endtrans %}
This doesn't work so I tried to put this in a variable:
{% set allInName = 'all.in.{{ countryKey }}' %}
{% trans %}allInName{% endtrans %}
But then the output is allInName
and not the translation. Someone an idea what I'm doing wrong?
THNAKS!
Upvotes: 5
Views: 4334
Reputation: 2263
You could try to do it like this :
{{ ('all.in.'~countryKey)|trans }}
already tested this works. the '~' sign is to concatenate, and |trans filter translate
Upvotes: 9
Reputation: 1315
Try
{% set allInName = 'all.in.' ~ countryKey %}
{{allInName | trans}}
Upvotes: 1