【问题标题】:JMSI18nRoutingBundle symfony2 create the routing tranlationsJMS I18n Routing Bundle symfony2 创建路由转换
【发布时间】:2013-08-03 14:02:45
【问题描述】:

我在 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 }

到路线,它可以工作(这是“保留未翻译的路线”)

正如我所见,这仅仅意味着“他”当地人的路线根本不存在。

一个想法如何实现它?

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

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 app/console router:debug 说了什么?
  • 只是加了一部分 扒子

标签: php symfony


【解决方案1】:

你试过了吗

php bin/console 翻译:extract de --enable-extractor=jms_i18n_routing --dir=./src --output-dir=./app/Resources/translations

已经在控制台了?根据您的需要交换“德”。清除缓存后它对我有用。

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

【讨论】:

    【解决方案2】:

    说明书上写着:

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

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

    【讨论】:

    • 是的,我知道,但为什么这些路线不存在?我如何创建它们?
    • 路线确实存在,就像你的愚蠢表演一样。显然 router:dumb 没有显示包括域的完整路径。如果愿意,请接受我的回答并发布一个新问题。
    • 抱歉,我应该接受什么?你说的是众所周知的。 “他”站点版本如何设置路由?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-30
    • 2015-12-09
    • 2021-05-26
    • 1970-01-01
    • 2011-01-11
    • 2015-06-26
    • 1970-01-01
    相关资源
    最近更新 更多