Hi.
I have a problem about changing the language in the front-end for guest on the site.
In my index.php file I have the following code that I thought would to the trick, but no :(
$uri_parts = explode('/', $_SERVER['REQUEST_URI']);
if(empty($uri_parts[1])) {
$uri_lang = 'en';
$lang = 'english';
} else {
$uri_lang = $uri_parts[1];
switch($uri_lang) {
case en: $lang = 'english'; break;
case it: $lang = 'italian'; break;
case es: $lang = 'spanish'; break;
case de: $lang = 'german'; break;
case da: $lang = 'danish'; break;
case nl: $lang = 'dutch'; break;
case fi: $lang = 'finnish'; break;
case el: $lang = 'greek'; break;
case nb: $lang = 'norwegian'; break;
case pt: $lang = 'portuguese'; break;
case ru: $lang = 'russian'; break;
case sv: $lang = 'swedish'; break;
case chs: $lang = 'chinese (Simplified)'; break;
case cht: $lang = 'Chinese (Traditional)'; break;
}
}
$assign_to_config['template_group'] = '';
$assign_to_config['template'] = '';
$assign_to_config['site_index'] = '';
$assign_to_config['site_404'] = '';
$assign_to_config['global_vars'] = array(
"country_code" => $uri_lang,
"language" => $lang,
"user_language" => $lang
); // This array must be associativeI have tested in a browser that where complete cleared from cookies and browser history. When going to a URL like mydomain.com/sv/ the part of the site that is translated to Swedish should change to Swedish, but the don’t. They are still in English.
the country_code, language and user_language returns right value so no problem there.
Anyone have a suggestion whats might be wrong or have a solution on this?
If I’m logged in and set my language to Swedish in my profile, it works as it should.
/ Mattias