[英]Symfony 3 | JMSi18nRoutingBundle doesn't translate routes
Guys I was using BeSimplei18nRoutingBundle but using some JMS bundles too, so I wanted all to be JMS bundles and changed it to JMSi18nRoutingBundle. 伙计们,我当时使用的是BeSimplei18nRoutingBundle,但也使用了一些JMS捆绑软件,因此我希望所有人都成为JMS捆绑软件,并将其更改为JMSi18nRoutingBundle。 Now my locale based routing working perfectly, but I cannot translate them.
现在,我基于语言环境的路由可以正常工作,但是我无法翻译它们。 Looked everywhere and cannot create/find a solution.
随处可见,无法创建/查找解决方案。
First, I installed JMS's routing and translation bundles. 首先,我安装了JMS的路由和转换包。 Added to AppKernel.
已添加到AppKernel。
After that, added routing configuration to config.yml file: 之后,将路由配置添加到config.yml文件:
jms_i18n_routing:
default_locale: tr
locales: [tr, en]
strategy: prefix_except_default
Then, added 2 routes to routing.yml file: 然后,将2条路由添加到routing.yml文件:
homepage:
path: /
defaults: { _controller: AppBundle:Default:index }
options: { i18n: true }
secondpage:
path: /ikincisayfa
defaults: { _controller: AppBundle:Default:secondPage }
options: { i18n: true }
After that I extracted translation file for en locale on console: 在那之后我提取翻译文件连接控制台上的语言环境:
php bin/console translation:extract en --bundle=AppBundle --enable-extractor=jms_i18n_routing --output-format=yml --exclude-dir=cache --exclude-dir=data --exclude-dir=logs --exclude-dir=Tests --exclude-dir=Service --output-dir="app/Resources/translations"
And translated ikincisayfa to secondpage : 并翻译ikincisayfa到secondpage:
# Desc: /
homepage: /
# Desc: /ikincisayfa
secondpage: /secondpage
But when I run php bin/console debug:router here is the output; 但是,当我运行php bin / console debug:router时,这里是输出; no translation happened:
没有翻译发生:
tr__RG__homepage ANY ANY ANY /
en__RG__homepage ANY ANY ANY /en/
tr__RG__secondpage ANY ANY ANY /ikincisayfa
en__RG__secondpage ANY ANY ANY /en/ikincisayfa
Tried to clear cache, re-extract translations but no luck.. Can someone say where I am doing the fault please.. Thank you. 试图清除缓存,重新提取翻译但没有运气..有人可以说出我在哪里做错了..谢谢。
Ok, I've found the problem.. I wasn't deleted the created-by-symfony routing in routing.yml file: 好的,我找到了问题..我没有在routing.yml文件中删除由symfony创建的路由:
app:
resource: '@AppBundle/Controller/'
type: annotation
It seems, this caused a conflict between Symfony's routing and JMS' router. 看来,这引起了Symfony的路由和JMS的路由器之间的冲突。 I wish JMS' documentation had these information too.
我希望JMS的文档也有这些信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.