homepage Welcome to WebmasterWorld Guest from 54.234.228.64
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Detecting Language Of Visitor
detect browser
erika1959




msg:1481508
 6:22 am on Jan 9, 2003 (gmt 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?

 

tedster




msg:1481509
 6:43 am on Jan 9, 2003 (gmt 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]

hakre




msg:1481510
 6:44 am on Jan 9, 2003 (gmt 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.

BjarneDM




msg:1481511
 12:00 pm on Jan 10, 2003 (gmt 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.

andreasfriedrich




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

See section 14.4 Accept-Language of RFC2616 [faqs.org].

Staffa




msg:1481513
 1:17 pm on Jan 10, 2003 (gmt 0)

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

Just curious to know.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved