我正在做一个 Symfony2 项目,并有一个问题.在一个 twig 模板中,我从控制器接收到一个变量.这是一个字符串,我需要翻译它.但是语法
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???
使用 过滤器:
{{ post['name']|trans }}