How to change the language correctly? What to set? Cookie? Config variable? request parameter?

translations
seo
oxid6
#1

Hello,
I am trying to make a change language functionality for a multilingual shop. So, the problem is that I can’t understand how the oxid default functionality manages it. The are a lot of variables related to language. What exactly should I set in order to make the change correctrly? I see the language cookie which is always uptodate with current language. I have scanned whole project and didn’t find even where is being creating. Nothing relative in code to this cookie. What hapens when the current url where the user is, is seo url?

Best regards.

#2

Hi,

you just have to add ?lang= to the URL. If you put it together in the templates you can also use [{ oxgetseourl }] to make a nice looking URL if there is one available throughout the system.

You can check the Languages and their IDs in the Backend Language Settings.

Cheers,
Thorsten

#3

You can find the relevant code in core/Language.php or core/oxlang.php, the cookie is set there:

\OxidEsales\Eshop\Core\Registry::getUtilsServer()->setOxCookie('language', $this->_iBaseLanguageId);

Right above you can see how language is determined.

Each language has its own SEO-urls, but you can override language by get parameter.

#4

Thank you responce.
I have tried adding ?lang=langId to url… yes the language changes, but the cookie remains unchanged. If I proceed to new tab to homepage of shop, it’s being loaded on shops default language. You are right about setOxCookie() I found it in core/Language.php as you said, but only once in whole project. nowhere else. I have changed by my self the value of language cookie. I have set also the base language ($oLang->setBaseLanguage()) in every case, something is going wrong. E.g. after setting both(baseLang, cookie) the language cookie value is being changed from request to request (1 request: language cookie 3(spanish), second request language cookie 0(Deutsch default lang) next request again Spanish and so on), Are there any ideas?

#5

What are you trying to achieve?

PS: just tried in demoshop, if i change lang by parameter the cookie does change and shop is loaded in new language in new tab. What version do you use?

#6

Thank you all for advices, finally it has worked. The problem was the ald functionality of module wich had imact on language setting. So, the url parameter now does it’s work. Thanx!