Symfony 4.4.2 切换语言环境 - TWIG 中的语言环境缺失

问题描述

我使用全新安装的 Symfony 4.4.2 版本,我想创建 _locale_switcher.html.twig。就像在本教程中一样:https://medium.com/@ikerib/symfony-4-change-locale-9c39848760ec

我没有在树枝中得到 locales。我明白了,我必须从绑定中获取它:

_defaults:
    autowire: true      # Automatically injects dependencies in your services.
    autoconfigure: true # Automatically registers your services as commands,event subscribers,etc.
    bind:
        $locales: '%app.locales%'
        $defaultLocale: '%locale%'

或者我必须设置一个新的全局变量?

我也想知道为什么在我的版本中,参数 app_locale 是 app.locale。

parameters:
    locale: de
    app.locales: de|en

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...