I have a problem with routing and the internationalization of my site built with Symfony2.
If I define routes in the routing.yml file, like this:
exampl
There is my Solution, it makes this process faster!
Controller:
/**
* @Route("/change/locale/{current}/{locale}/", name="locale_change")
*/
public function setLocaleAction($current, $locale)
{
$this->get('request')->setLocale($locale);
$referer = str_replace($current,$locale,$this->getRequest()->headers->get('referer'));
return $this->redirect($referer);
}
Twig:
-
{{ language.locale }}