Forum Moderators: open

Message Too Old, No Replies

Automated recognition of the browser language

         

tamel

6:24 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Hi , i'm kind of new to web pages making and i want to know if there is a java script or html code i can use , so when someone tries to access my site that will redirect him to the appropriate language his brower has. I want him to be redirected to either english or russian site. Thx.

Rumbas

7:58 am on Jul 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi tamel, welcome to the forums :)

I see what you mean and that it would be good service for your users if they automatically get redirected to the appropriate language. However my own feel is that I what to choose what language I want to see.

Secondly you could run into problems with the search engines, if you run an automatic redirect. I would use flags in stead - give the users an option to click on the flag/language of their choice.

tamel

8:05 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Thx for the welcoming Rumbas. I already have that in my site (the flags) but i just wanted to see if something like that is possible. :) And if yes i would like to give it a try.

tedster

11:42 am on Jul 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a language code that browsers are supposed to return if requested, called ISO 639. The W3C has a page of ISO 639 language codes [w3.org] you may find useful in your experiments.

The javascript object to read is not standardized, as far as I know -- it's either navigator.language in Netscape or navigator.userLanguage in Explorer. Not sure about Opera / Mozilla etc but a bit of experimenting should tell you which is which. I doubt that any browser invented yet another object name.

IE, because of its infamous integration with the operating system, can also read the system language through the systemLanguage object. Here's a Microsoft reference [msdn.microsoft.com] on the topic.

Because so many computers are shipped with English as the default language, and so many users do not change this default, you cannot count on the user's preference to be indicated by the brower when it says English. So I agree with Rumbas, keep the national flags. And don't re-direct every visitor because that certainly can get you in trouble with the search engines.

I'd suggest having one default page in your most common visitor languge. Then from that page, use an external javascript to sniff for the browser langauge and re-direct those who are clearly different.