14

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???

1 Answer 1

29

Use filters:

{{ post['name']|trans }}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.