Prefix routes with dynamic locale depending on user preferences - symfony 4

26 views Asked by At

I’m trying to make the base locale change depending on the user preferences. I know I can change the prefix rules in the config, but I don't know how to them make dynamic.

app:
    resource: "../src/Controller/"
    type: annotation
    prefix:
        ?: '' # don't prefix URLs for the default locale
        ‘fr|de|es’: ‘{_locale}’

Let’s assume we have Client A and Client B.

Client A

  • Base: EN
  • Secondary: DE, FR


Client B

  • Base: FR
  • Secondary: ES

For the base locale I don’t want any prefix, only for secondary locales.

Example for Client A

‘en’: ‘’
‘de’: ’/de’
’fr’: ‘/fr’

Example for Client B

‘fr’: ‘’
‘es’: ‘/es’

Any clue on how can I achieve this through Symfony? Thanks.

0

There are 0 answers