How to set {locale} in every url in symfony 2?

How do you do this? But if possible, avoid it for a particular language

Writing it down for every URL is annoying ..

For example: I want my site to respond to / and / fr-FR / for each URL. First for English, last for French.

+4
source share
2 answers

You should take a look at the JMSI18nRoutingBundle , add support for internationalizing routes without duplicating the definition of routing.

This kit comes with three scenarios for recounting routes. Your example is perfect for scenario 2 , which is "Prefixing All Routes With The Locale except those of the default locale"

+6
source

In your routing.yml you might have something like (if you use yaml to configure routing:

 AcmeTestBundle: resource: "@AcmeTestBundle/Resources/config/routing.yml" prefix: / 

Have you tried adding {locale} to the prefix?

+1
source

Source: https://habr.com/ru/post/1381549/


All Articles