$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
case "nl":
//echo "PAGE FR";
include("talen/nl.php");//include check session FR
break;
case "es":
//echo "PAGE IT";
include("talen/es.php");
break;
case "en":
//echo "PAGE EN";
include("talen/en.php");
break;
default:
//echo "PAGE EN - Setting Default";
include("talen/en.php");//include EN in all other cases of different lang detection
break;
}
But when I set browser language to "af" it doesnt get the default english language...
How can I make that happen?
I have no case "af" so it doesnt show anything...
When there is no case like "af" I want the default to be "en" but that doesnt work
This is another solution I tried but no luck either:
<?
$accept_lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$accept_lang = str_replace(' ', '', $accept_lang);
$arr = explode(',', $accept_lang);
$lang = "en";
$q = 0;
if (count($arr) > 0) {
foreach ($arr as $a) {
$l = explode(';', $a);
if (count($l) == 1) {
$l[1] = 'q=1';
}
$l[1] = str_replace('q=', '', $l[1]);
if ($l[1] > $q) {
$q = $l[1];
$lang = $l[0];
}
}
}
$lang = preg_replace('/-(.*)/', '', $lang);
switch ($lang){
case "nl":
//echo "PAGE FR";
include("talen/nl.php");//include check session FR
break;
case "es":
//echo "PAGE IT";
include("talen/es.php");
break;
case "en":
//echo "PAGE EN";
include("talen/en.php");
break;
default:
//echo "PAGE EN - Setting Default";
include("talen/en.php");//include EN in all other cases of different lang detection
}
?>
My $lang is still set to "af" and not the default "en"

New Topic/Question
Reply




MultiQuote




|