A couple of days ago I quipped:
Which, apparently, struck some sort of nerve as it got favorited and retweeted above my usual average. And that prompted me to explore this topic a little more from a technical standpoint.
But, first, a little bit of history.
What originally angered me was the fact that some websites insist on offering me a German language experience of their site, despite the fact that I deliberately switch all of my computers, phones, televisions, and vacuum cleaners to use the English language, because, well, that’s how I roll.
The Difference Between Shopping and Information
Shopping sites like Amazon have every right in the world to send me to their local offerings if they detect that I’m coming from a certain country where they have a local presence in. (More on that detection in a bit.)

Friendly reminder to shop locally
Yet, they don’t. They simply offer a friendly banner at the top of Amazon.com that informs me of a local offering I might be interested in. (And I am.)
Compare and contrast that with sites like Softonic, which slap me in the face with a modal dialog – requiring an immediate decision on my part – suggesting I use their site in German instead of the version that I chose to access and which matches the language of my browser.

Modal language dialog at Softonic
While I appreciate the fact that they may be employing a CDN for speedy downloads from a local server, this is an implementation detail independent from the actual language used on their site, which I don’t really happen to care about to be in the language of my geographic location (as opposed to the language of my browser and operating system).
(And I’m not trying to single out Softonic here. This forced language detection based on geographic location instead of browser language seems to be common practice. Softonic just happened to be the site that prompted the tweet embedded above.)
Odd Birds and Travelers
I may well be the odd bird in this case in that my geographical location does not match the preferred language set in my browser.
But what about travelers?
Everyone traveling abroad is probably in the same boat as I am. Potentially even worse, given that their foreign language skills may not be as fluent and a foreign language version of a site (that is not a shopping site) may be of even less interest.
Technical Hurdles
Detecting the geographic location of a visitor to your site is a non-trivial task. It usually involves some kind of third-party service doing a geolocation lookup, which means a round-trip to at least one other server before you can even render the first page view to your visitor, delaying the often crucial first impression the visitor gets by a couple hundred milliseconds.
While this is a necessary evil for DRM-plagued services such as Netflix and targeted online advertising to use geotargeting as part of their offering, using a geolocation for the display language of your website is just plain overkill.
Why? Because every modern browser sends its language preference (or, more appropriately, that of its user) along with every HTTP request being made in the form of the Accept-Language header that is part of the HTTP/1.1 RFC.
The Accept-Language request-header field is similar to Accept, but restricts the set of natural languages that are preferred as a response to the request.
It’s even possible to supply multiple languages with appropriate weightings:
Each language-range MAY be given an associated quality value which represents an estimate of the user’s preference for the languages specified by that range.
So without round-tripping to (potentially non-free) third-party services in order to find out where your visitor is coming from, you can simply use the Accept-Language header supplied by the visitor in most situations to make an even more informed decision what their language preference may be.
Lead by example
In Rails, the value of the Accept-Language can be found in request.headers[‘HTTP_ACCEPT_LANGUAGE’].
This is, for example, the value supplied by Chrome 17 when set to the English language:
Accept-Language: en-US,en;q=0.8
If you switch it to German, it’ll send:
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Basically, this list specifies German as the most desired language, US-English as the middle ground, and, if all else fails, any dialect of English will do.
Other browsers like Firefox and Safari supply similar values for Accept-Language, albeit not as detailed.
Great further reading on the topic of internationalizing a Rails application is the Guide on the Rails I18n API and Iain Hecker’s http_accept_language gem.
If you’d like to use this header in JavaScript and don’t have a way to pass it to the Javascript layer from your app (I heard those cases exist), there’s a helpful jQuery plugin from Dan Singerman called jQuery Browser Language, which gives you access to this header otherwise unavailable to JavaScript.
Conclusion
Don’t force people to use your site or web application in a language they didn’t request just because they happen to sit in a spot on this planet where people usually speak it. Don’t use geotargeting for language detection just because you can. Instead, make use of established practices such as the Accept-Language header to deliver a much better user experience and much more likely matching their expectations.