Hey, so I’m building a multi language app. Let’s say we have 2 languages, en and fr. I’m using the localeurls extension to implement the language key (en, fr) into the URL, and I also add UrlRules for each language. For example, I will have:
‘loginEN’ => ‘site/login’ - when the language is en
‘loginFR’ => ‘site/login’ - when the language is fr
My problem is, how do I make a widget for changing the language, redirecting to the current URL, but in the new language that was selected. If I am on www.site.com/en/loginEN, when building the link for fr language, I would get www.site.com/fr/loginEN not www.site.com/fr/loginFR . Why? Because createUrl creates my link based on current URL rules. But I have new rules for fr, that get inserted dynamically, and apply of course, only after the app reloads with the new language code in the URL.
So what I want to do, is create a link to the current URL, with the new language code, and using the ‘future’ UrlRules for that language. Is that possible ? I guess not … One way I could do this is when creating the URL, temporary ignore the UrlRules, and create a link having the controller/action in original form, no rules applied. Then the new rules would get applied when the link is clicked and the app refreshed. How do I do that ?
Thank you !