问题
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:
Use filters:
{{ post['name']|trans }}
来源:https://stackoverflow.com/questions/9632502/symfony2-twig-translate-variable-values-in-trans-tag