2
它已经越来越晚了,我想我的大脑正在关闭...对于我的生活,我无法弄清楚如何更改翻译键以使用currentType
。在模板中使用Symfony翻译中的Twig变量
{% set currentType = site.getCurrentType() %}
{{ 'messages.site.{currentType}'|trans({ '%url%' : path('appbundle_course_url', { 'subdomain': site.subdomain }) }) }}
我正在做一些反常的事情,当我看到解决方案时会踢自己。我只知道它。
' 'messages.site。' 〜currentType'? – DOZ
@DOZ谢谢,我曾试过。它确实将字符串连接在一起,但不会转换。我留下了一个'messages.site.typenamehere'的输出。 (是的,我已经清除Symfony缓存和双重和三重检查翻译)... – crmpicco
简单的问题:如果你直接把正确的值,而不是Twig变量,翻译工作(只是可以肯定)? – DOZ