The first output the string not translated:
{{ chart.name~'.short'|trans({}, "charts") }}
This one works (is the same text that chart.name~'.short'
should output):
{{ 'charts.region.area.short'|trans({}, "charts") }}
Am i missing something? It seems it's impossible to translating dynamic text in Twig?
EDIT: working setting a variable (why?):
{% set name = chart.name ~ '.short' %}
{{ name|trans({}, "charts") }}
Symfony/Twig is trying to translate .short
and concatenate it with contents of chart.name
. Use parentheses to get the expected output:
{{ (chart.name~'.short')|trans({}, "charts") }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With