Sorry, it's hard to explain:
the easiest may be you exchange this part of the orignal code:
Code:
foreach ($langOpts as $key=>$language) {
$lang = explode(',',$language);
foreach ($lang as $subLang) {
if (trim($subLang) === $http_lang) {
$visitor['languageId'] = $key;
$visitor->setVisitorLanguage($key);
XenForo_Helper_Cookie::setCookie('language_id', $key, 86400 * 365);
return;
}
}
}
with this modified code
Code:
foreach ($langOpts as $key=>$language) {
$lang = explode(',',$language);
foreach ($lang as $subLang) {
if (trim($subLang) === $http_lang) {
$visitor['languageId'] = $key;
if (XenForo_Visitor::getInstance()->get('language_id')== 0){ //check if cookie is set (by Sankisan)
$visitor->setVisitorLanguage($key);
XenForo_Helper_Cookie::setCookie('language_id', $key, 86400 * 365); //set the language cookie (by Sankisan)
}// end Cookie check (by Sankisan)
return;
}
}
}
The other parts of the code keep untouched, so just add 3 lines (the ones followed by // )
This will add 3 lines to the code fixing these problems
At least it works fine at my page.
This modification will do the following (for guests only)
Check if the language cookie has been already set.
Case 1: Cookie not set: It will set the language to to the browser settings, and stores it into a cookie
Case 2: Cookie has been already set (by language chooser or because the guest is visiting again), it will do nothing
So only very new guest visitors will get the language of their browswer, once they have a cookie, their language will not autoset anymore, that's why they can still change the language to another language if they are just visitors.
Let me know if you have any additional qestions.
It works fine on my page (as far as I have tested), but it is still some kind of guessing, since I'm very new to the xenforo, so I would be glad if any developer could confirm my modifications... thanks
...alex