Welcome to WebmasterWorld Guest from 54.196.233.208

Forum Moderators: open

Message Too Old, No Replies

Detecting Language Of Visitor

detect browser

     
6:22 am on Jan 9, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 4, 2002
posts:39
votes: 0


A client has website which he's written in a number of languages which are organised in separate directories. At the moment, the surfer is directed to the French home page, and can find the his/her language by clicking on flags.

The client wants to up a step by being able to detect the surfer's language just after the surfer has clicked on his search engine listing and have that surfer automatically directed to the correct language.

Is there a script available which will do this?

6:43 am on Jan 9, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


You may find this thread [webmasterworld.com] of interest. The consensus there seems to be that auto-detection of language is not a good idea in many cases. You can read the comments in the thread and judge for your self how they apply to your situation.

As to a script, I found this snippet tucked away (had to blow the dust off it!) It purports to do what you asked - that is, check for what "prefered language" was chosen in the browser setup. But I've never used it and can't vouch that it's dependable. In particular, it is an old script so I'm not sure that these are the current names for the object you need to check in more recent browsers.

<SCRIPT LANGUAGE="JavaScript1.2"><!--
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;
//--></SCRIPT>

[edited by: tedster at 7:22 am (utc) on Jan. 9, 2003]

6:44 am on Jan 9, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 7, 2003
posts:1230
votes: 0


each user can setup his browser, sothat the browser can tell the server which language is prefered. apache has this feature build in for example. in this case you only need to add the countrycode at the end of the document, if it's index.html for example, you name it index.html.fr for french, index.html.de for german etc. pp.

if you're using apache, take a look into the docs.

12:00 pm on Jan 10, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Dec 22, 2002
posts:334
votes: 0


problem is: how many are aware that they can set their browser up so that the server gets information about the preferred language?

I've looked into the Apache automatic detection and found it wanting in everyday practical life. It's a great feature, *IF* users did select the language preference in their browsers - otherwise its problematic.

you can do the Apache serverside identification, but for safety's sake do also still offer the manual selection.

12:44 pm on Jan 10, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


See section 14.4 Accept-Language of RFC2616 [faqs.org].
1:17 pm on Jan 10, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 24, 2002
posts:894
votes: 0


What would happen if a user's browser was set for several languages?

Just curious to know.