PDA

View Full Version : Redirect only if "en" is the browser language


slurpey
05-16-2008, 09:57 PM
Hi,

I've been trying many language detection scripts but failed so far to achieve this:

I want to detect the language of the browser and if it starts with
en
(such as in en-ca, en-uk, en-us, etc) it redirects to a specific page.
Otherwise, for all other languages, it just goes on loading.

All my atemps worked either on firefox or IE but never on both when I tested by changing my language preference.

I need to send all english speaking traffic to a specific website, while any other language is welcome to visit the page(s). So I'd like to make an <include> at the begining that would filter out all english speaking. I can make the include, but not the script ;)

All help is super welcomed.

Thanks,
Lloyd

chump2877
05-17-2008, 12:47 AM
Detecting client side settings, especially using JavaScript as opposed to a server side script to do so, is a crap shoot at best...Redirecting a page with JavaScript is worse...

Instead of detecting browser settings with any script/language (a generally unreliable method), why not have an initial page that allows the person to select which language they want. Then redirect the person to the appropriate page with server side code.

i.e.,

http://www.firestoneag.com/
http://www.spanishincadiz.com/ingles/ingchooselanguage.htm
http://www.touchgenerations.com/

The last link uses Flash, which is another safe option...

slurpey
05-17-2008, 08:16 PM
I agree on the usability stand point that what you suggest is a better idea. My problem is I developed a "European" website in different languages using a different look and feel as the "official" company-wide (ugly) one.

And in order to avoid political drama, I want to simply make this website not available for the US!

I also would like to have the minimal maintenance possible, that's why I ruled-out geolocation.

Once again, thanks for all help.

Lloyd

Twinkie
05-21-2009, 11:07 PM
Geolocation can be simple if you find a free service. I use bytebuffet.com. They have several geolocation and mapping services that are free. The documentation is good and there are samples.