JMSI18nRoutingBundle符号2创建路由传输


JMSI18nRoutingBundle symfony2 create the routing tranlations

我在symfony2中使用JMSI18nRoutingBundle。

我看了所有的文档-->http://jmsyst.com/bundles/JMSI18nRoutingBundle

并使用3。我的配置中的场景:

jms_i18n_routing:
    default_locale: en
    locales: [en, he]
    strategy: custom
    hosts:
        en: example.com
        he: example.co.il
    redirect_to_host: false

我甚至试着用2。场景

这将简单地为其他语言的url添加一个前缀。

正如我所看到的,我的问题是当我进入网址时:example.co.il

它说找不到路线。当我添加这个->选项:{i18n:false}

对于路线,它是有效的(这是针对"未翻译的离开路线")

在我看来,这只是意味着"他"当地人的路线根本不存在。

一个想法我该如何实现它?

根据请求,这是我的路由器:debug-->(我只加了一部分,因为它很长)

he_en__RG__site_base_homepage            ANY    ANY    ANY  /
he__RG__site_base_homepage               ANY    ANY    ANY  /
en__RG__site_base_homepage               ANY    ANY    ANY  /
he_en__RG__site_base_about               ANY    ANY    ANY  /about
he__RG__site_base_about                  ANY    ANY    ANY  /about
en__RG__site_base_about                  ANY    ANY    ANY  /about
he_en__RG__site_base_contact             GET    ANY    ANY  /contact
he__RG__site_base_contact                GET    ANY    ANY  /contact
en__RG__site_base_contact                GET    ANY    ANY  /contact
he_en__RG__site_base_contact_verify      POST   ANY    ANY  /contact
he__RG__site_base_contact_verify         POST   ANY    ANY  /contact
en__RG__site_base_contact_verify         POST   ANY    ANY  /contact
he_en__RG__terms_of_use                  ANY    ANY    ANY  /terms
he__RG__terms_of_use                     ANY    ANY    ANY  /terms
en__RG__terms_of_use                     ANY    ANY    ANY  /terms

你试过吗

php-bin/console转换:extract-de-enable-textractor=jms_i18n_routing-dir=/src--输出目录=/应用程序/资源/翻译

已经在控制台上了吗?根据您的需要交换"de"。清除缓存后,它对我有效。

PL小心使用,因为它删除了我messages.de.yml文件中的一些翻译。

手册中说明:

每当模式与不同主机的区域设置匹配时,都会使用重定向,除非redirect_to_host设置为false,在这种情况下会引发ResourceNotFoundException,这通常会导致404错误。

因此,如果您将redirect_to_host设置为false ,这是正常行为