Website Language Detection

If you are like me, you probably visit a lot of websites. As a native English speaker we certainly have access to some of the best online resources specifically written in our native English. However, there are times when I visit sites that support multilingual versions but force me into a language other than English.

Ouch! That can really dampen my user experience. Instead of finding out what your site offers, I have to first find a way to get it to display in my chosen language.

Sure, so maybe my IP address is based in Mexico, but should your website assume I speak Spanish? That may be a good assumption if you had nothing else to go on, but there is something better. My web browser, when it was installed on my computer, tablet, smart phone, TV etc., adopted the language of my operating system or host device, which makes perfect sense. That same language assumption should roll over into my web browsing experience.

HTTP headers to the rescue

Web browsers typically share my language preferences with the websites I visit using an HTTP header. (see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). Using the accept-language header, the browser can share with the website the user’s language, localization and preferences among multiple languages. Website developers can parse this header to determine the best language match to serve to their visitor.

Users can change their language preferences via their browser settings, thus customizing or overriding the defaults provided. And if that is not enough or feasible, those websites that support multi-lingual versions should clearly present the option to change the language and remember the visitor’s choice via a cookie.

Unfortunately, I see too many websites failing to do this properly. With the use of Virtual Private Networks (VPNs) and Tor browsers, the IP address of your visitor may have zero correlation to their actual location, so stop using IP address as your primary means to select the language for your website visitors. IP’s are not synonymous with your visitor’s country, and countries are not synonymous with your visitor’s language preference.

With so many online experiences being tailored for a global audience, be sure your website gets this most basic concept right.