Symfony2: How to implement locale switcher with actual URI?
All! How to implement locale switcher with开发者_如何学Go actual URI and parameters ??
Current page and locale (DE):
<en><DE>
mysite.com/de/controller/action/show/slug
User clicks on EN link
<EN><de>
mysite.com/en/controller/action/show/slug
locale switches, but the previous URI restored two
Any ideas ?? Thks in advance!
For the routing part, you can look at theses plugins:
- http://symfony2bundles.org/BeSimple/BeSimpleI18nRoutingBundle
- http://symfony2bundles.org/schmittjoh/JMSI18nRoutingBundle
If you want to change your locale (do it very early with a kernel listener for example) :
$container->get('session')->setLocale('en');
精彩评论