Hi,

I'm getting a little paranoid with a dual language website I built.

What I want to happen:

If a user arrives with an EN browser or a browser with EN as the primary language setting then the language of the site is in English.

If any other language then the default language of the site is ES (Spanish).

In both cases a cookie is set to store the data.

In both cases the user has the option to change the language (and the cookie be updated).

I thought I had this working, but have noted erratic behaviour with languages in the last few days (language not being set, changing from page to page).

My first code was as follows:

//SET LANGUAGE
if(isset($setlang)) {
$lang = $setlang;
setcookie ("langset", "$setlang");
} else {
if(isset($langset)) {
$lang = $langset;
} else {
if (!isset($lang)) $lang=substr($HTTP_ACCEPT_LANGUAGE,0,2);
setcookie ("langset", "$lang");
}
}

One problem I quickly realsed with this version was that it did not take account of users with browsers that were *not* ES or EN. So a modified version was produced to set the language to ES where the ACCEPT_LANGUAGE request was neither ES or EN:

//SET LANGUAGE
if(isset($setlang)) {

// IF LANG IS NOT ES OR EN SET TO ES
// ADDED 03032003 TO FIX LANG ERRORS
if (($setlang != "en") && ($setlang != "es")) {
$setlang = "es";
}

$lang = $setlang;
setcookie ("langset", "$setlang");
} else {
if(isset($langset)) {
$lang = $langset;
} else {
if (!isset($lang)) $lang=substr($HTTP_ACCEPT_LANGUAGE,0,2);
// IF LANG IS NOT ES OR EN SET TO ES
// ADDED 03032003 TO FIX LANG ERRORS
if (($lang != "en") && ($lang != "es")) {
$lang = "es";
}

setcookie ("langset", "$lang");
}
}


Now, after all is said and done I'm a little confused as the newer script still seems to give erratic behaviour and I've been looking at it too long to see clearly.

Can anyone offer advice or suggest a better way to do this?

The site is question (now back to version one of the script) is at http://www.circulodelarte.com/

Many thanks,

Gary Crighton