Forum Moderators: phranque

Message Too Old, No Replies

browser language recognition

how to make your website recognize browser language

         

ilustrate

8:06 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



i'm trying to figure out how to get my site to recognize the browser language that the customer is using when visiting the site. does anyone know of a effective way. i´ve decided to use the infrastructure for the site language distribution in .html form. i noticed that www.skype.com uses www.skype.com/intl/es/ for spanish www.skype.com/intl/it/ for italian and so on. i think this is a great simple approach but how do i actually get the main site. www.mysite.com to actually make the www.mysite.com/intl/es/ to start when a spanish speaking visitor arrives? Is this .htaccess?

jdMorgan

8:29 pm on Jul 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This could be done in .htaccess or httpd.conf by testing the HTTP Accept_Language header, or by using MultiViews (see mod_negotiation).

Another common answer to this kind of question is to let the user select the language by using links, national flag icons, national subdomains, etc. The usual comment being, "Just because the browser is set to a certain language or the ISP resolves to a certain geolocation doesn't mean the user speaks that language." If a user's ISP resolves to Canada, do they want French or English? How about Belgium, or other multilingual countries? Internet cafes and other "public computers" in large cities also come to mind.

So, the common advice is, let the user choose, then offer a cookie to save the setting if the machine is their personal machine.

Jim

encyclo

8:33 pm on Jul 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The basic requirement for adjusting your content to the user's preferred language is based around the fact that most browsers send an
Accept-Language
header with each request that you can parse to determine which language to serve.

You have two possible approaches (both related): the first is to use Apache Content Negotiation [httpd.apache.org] to determine the most appropriate language file to serve. The second approach is to use server-side scripting (PHP, ASP, etc.) to do the content negotiation.

Spiders and older browsers don't usually send an

Accept-Language
header, so you will need to specify a default.