1

我的项目在 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>

你有什么主意吗 ?

先感谢您。

4

1 回答 1

0

我找到了解决方案。

为了在开发模式下工作,我必须使用“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
于 2017-03-29T12:20:35.773 回答