Welcome to WebmasterWorld Guest from 107.20.110.201

Forum Moderators: open

Message Too Old, No Replies

Detecting Language Of Visitor

detect browser

     

erika1959

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

10+ Year Member



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

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

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



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

Staffa

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

WebmasterWorld Senior Member 10+ Year Member



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

Just curious to know.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month