Reputation: 23
I'm using JMSI18nRoutingBundle for locale routing on our new site, but our existing site uses language + country in the following format and I need to keep the URLs looking the same.
Is there any way to do this using config? If not, where is the best place to start customizing?
Upvotes: 1
Views: 141
Reputation: 9246
It doesn't look it's possible to do through config, but it can be done by replacing default implementation of PatternGenerationStrategyInterface by your own implementation.
You can check out default implementation that bundle uses here.
After you create your own implementation, just make bundle use your own implementation by setting the config parameter. If you're using YAML for example:
parameters:
jms_i18n_routing.pattern_generation_strategy.class: YourBundle\YourImplementationClass
Hint: you can basically copy/paste from default implementation and change line 69 to use str_replace('_', '/', $locale)
instead of just $locale
. That way, newly generated route pattern will contain a /
if locale contains an _
.
Not very elegant solution, but bundle unfortunately doesn't provide enough configuration to make it prettier.
Upvotes: 1