Created
March 29, 2018 13:25
-
-
Save sufimalek/29a89f45616ff7fcedb035112aca31dd to your computer and use it in GitHub Desktop.
internationalization in symfony2/3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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); | |
} | |
<li {% if app.request.locale == language.locale %} class="selected" {% endif %}> | |
<a href="{{ path('locale_change', { 'current' : app.request.locale, 'locale' : language.locale } ) }}"> {{ language.locale }}</a> | |
</li> | |
https://stackoverflow.com/questions/7903477/symfony2-default-locale-in-routing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment