Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 twig translate variable values in {% trans %} tag

I'm working on a Symfony2 project and have a question from it. In one twig template I receive a variable from controller. It's a string and I need to translate it. But the syntax

{% trans %}{{ post['name'] }}{% endtrans %}

returns error "A message must be a simple text in...".

So is there a way to translate the variable values???

like image 962
ArVan Avatar asked Mar 09 '12 10:03

ArVan


1 Answers

Use filters:

{{ post['name']|trans }}
like image 66
meze Avatar answered Nov 13 '22 08:11

meze