2
在layout.html.twig文件中;FOSUserBundle理解树枝模板变量
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
<a href="{{ path('fos_user_security_logout') }}">
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
</a>
{% else %}
<a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
{% endif %}
什么是布局属性指的是?这似乎只是输出字符串,因为它是我的html页面即“layout.logged_in_as”和“layout.logout”
啊是有道理的。如何配置我的应用程序以使用翻译? – Sid
Symfony翻译器通常在新项目中被禁用(因为并非所有应用都需要翻译)。要启用它,[只需添加文档中提到的'framework.translator'配置项](https://symfony.com/doc/master/bundles/FOSUserBundle/index.html#translations)。 –