I set up a language switcher on my website but right now I only know how to redirect to the homepage:
public function englishAction(Request $request)
{
$this->get('session')->setLocale('en_US');
return $this->redirect($this->generateUrl('homepage'));
}
How can I do to redirect to the current page?
Try:
return $this->redirect($request->headers->get('referer'));
Or another solution: you may put back url link as a get parameter and use it in redirect in your "englishAction" action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With