【问题标题】:In Symfony 3.2.6 with BeSimpleI18nRoutingBundle, can't generate i18n routes in production mode在带有 BeSimpleI18nRoutingBundle 的 Symfony 3.2.6 中,无法在生产模式下生成 i18n 路由
【发布时间】:2017-03-28 08:18:51
【问题描述】:

我的项目在 Symfony 3.2.6 中,我尝试使用 BeSimpleI18nRoutingBundle 在生产模式下生成 i18n 路由。

在开发模式下,没关系。

但在生产模式下,生成的路由总是在相同的语言环境(当前)中。

(我已经清除了缓存)

我使用这些链接来切换:

<a href="{{ path(app.request.attributes.get('_route'), {'locale': 'fr'}) }}">fr</a>
<a href="{{ path(app.request.attributes.get('_route'), {'locale': 'en'}) }}">en</a>

你有什么想法吗?

提前谢谢你。

【问题讨论】:

    标签: php symfony routing translation symfony-3.2


    【解决方案1】:

    我找到了解决办法。

    为了在开发模式下工作,我必须像这样用“type: be_simple_i18n”更新“routing_dev.yml”中的“_main”路由:

    _main:
        resource: routing.yml
        type: be_simple_i18n
    

    生产模式的解决方案是在“config.yml”中添加同一行,其中“routing.yml”是这样导入的:

    framework:
        ...
        router:
            resource: "%kernel.root_dir%/config/routing.yml"
            type: be_simple_i18n
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-04
      • 2018-02-13
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      相关资源
      最近更新 更多