There is a multilingual website built in Symfony2. In the base layout, there is language switch something like this:
<a href="{{ path(app.request.attributes.get('_route'), {_locale: 'en'}) }}">EN</a>
<a href="{{ path(app.request.attributes.get('_route'), {_locale: 'fr'}) }}">FR</a>
This works fine switching languages without changing the current page. However, if there are other parameters it throws an exception because of ‘missing mandatory parameters’. How to overcome this?
You could do something like :
What this does is merge the _locale parameter with the existing query parameters.