1
votes

in my Symfony 3.3 project I use locale system to change the user language. I have configured my routing to allow the 'en' version for not having it in the url.

acme_front_office:
    resource: "@AcmeFrontOfficeBundle/Resources/config/routing.yml"
    prefix:   /{_locale}
    defaults: { _locale: 'en'}
    requirements:
        _locale: '|en|fr'

So those url redirect all to the same page :

/home
/en/home
/fr/home

But in my twig templates the {{ path() }} function set by default the right locale except that when my user see the english version of the website I want that the generated url head to /home and not /en/home.

If you have a clue on how to do that without changing all the path() calls to override the _locale param I will be very thankful.

Have a good day ;)

1

1 Answers

1
votes

So after some digging, the solution that I came up with is to rewrite some parts of the Symfony Routing system. If you want to check the solution you can find the code in the following gitlab repo, in the Routing dir.

TranslateBundle Repo