Reputation: 973
Guys I was using BeSimplei18nRoutingBundle but using some JMS bundles too, so I wanted all to be JMS bundles and changed it to 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. Added to AppKernel.
After that, added routing configuration to config.yml file:
jms_i18n_routing:
default_locale: tr
locales: [tr, en]
strategy: prefix_except_default
Then, added 2 routes to routing.yml file:
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:
# Desc: /
homepage: /
# Desc: /ikincisayfa
secondpage: /secondpage
But when I run php bin/console debug:router here is the output; 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.
Upvotes: 0
Views: 824
Reputation: 973
Ok, I've found the problem.. I wasn't deleted the created-by-symfony routing in routing.yml file:
app:
resource: '@AppBundle/Controller/'
type: annotation
It seems, this caused a conflict between Symfony's routing and JMS' router. I wish JMS' documentation had these information too.
Upvotes: 1