DEV Community

Pedro Pimenta
Pedro Pimenta

Posted on

Stop setting the language of your website based on user location

Please, stop!

Why

Setting the language of your website based on the user's location is not the best user experience. People travel, people move and not always do they speak the language of the place they're in.

I'm currently living in Germany for a while, and I know next to nothing of German, so it serves nothing showing me your content in German.

The worst offenders are the ones that first load the default (most of the times, in my experience, English) and then reload or re-paint to show me a language I don't understand.

The solution

A much better way (and probably easier) is to use the user's browser/system language. That's the language I want to read on 99% of the time. Otherwise, why would I have my machine in that language? And if it's not, I will change it myself.

So if my preferred language is English, it doesn't matter where I am, the content will be delivered in that language and I will understand it.

It's also super easy:

var userLang = navigator.language || navigator.userLanguage; 

Thank you. Signed,
Everyone

Latest comments (54)

Collapse
 
angielle profile image
Dannah

Thanks for the insight! I'm guilty of doing this.

Collapse
 
td540 profile image
td540

I completely agree and, if I may, I’d love to add the following: STOP STORING LANGUAGE PREFS IN COOKIES! Keep it in the URL and let everything else be! Thanks.

Collapse
 
bitdweller profile image
Pedro Pimenta

Oh. I don't agree with that. I'd like for the wbesite to store my favourite language so that when I return it can open in that language, without me having to think about the URL.

Collapse
 
maroun_baydoun profile image
Maroun Baydoun

Thank you for bringing this topic up.

Collapse
 
martinsanya19 profile image
Anya Martins Uchenna

Thanks man

Collapse
 
itsmylife profile image
ismail simsek

[insert michael scott "thank you" meme]

Collapse
 
bluesmoon profile image
Philip Tellis

Yelp is another example of l10n gone wrong. I have my language set to en_GB but all other locale settings are US, so they show me US restaurants with prices in pound sterling.

Collapse
 
bluesmoon profile image
Philip Tellis

Reminds me of the time I was transiting through Hong Kong for a day (this was in 2008). I had to get the street address of a local place. Found a computer kiosk at a tiny Museum of Tea! Unfortunately it was all in Cantonese, including the browser language setting. I went to yahoo.com but it redirected me to yahoo.hk or hk.yahoo.com (I don't remember). This was rather annoying and I worked at yahoo at the time.

Collapse
 
larsderichter profile image
Lars De Richter • Edited

Thank you so very much for this!

I live in Belgium. As some of you will know we are a country with three languages (not a bilingual country, mind you, one’s language will depend mainly on the region that they live in, Dutch in the north, French in the south and some German in the east; our capital Brussels is a special case: officially it's bilingual Dutch-French, but the numbers of speakers show a different story: French, English, Arabic (different dialects) and only then Dutch).

A lot of websites will mistakenly try to serve me in French (which is the second most spoken language). About 60% of the Belgian population has Dutch (Flemish) as their mother tongue. Although I can read French it takes a lot more effort than Dutch or English. Most of the younger generation is barely able to read or understand French and will prefer English over French all the time. Most teenagers will immediately exit a site in French.

My browser has my language preferences down to Dutch first, then English. My operating system is in English, so why serve me in French? Because I live in a country which has another region where French is the main language. If you are going to do it like this, then please don’t even bother with internationalisation and serve me in English.

For me it is not even a political thing like it would be for many of my countrymen. Imagine how they will react if you try to serve them in the wrong language.They would prefer being served in Ancient Greek over French...

Collapse
 
assertnotnull profile image
Patrice Gauthier

I just can't believe there's not even basic browser language detection in so many major website.

 
bitdweller profile image
Pedro Pimenta

ahahah :)

Collapse
 
bitdweller profile image
Pedro Pimenta • Edited

I think you can, on the footer, on the lower right corner. There should be a link to shop in english :)

Collapse
 
bitdweller profile image
Pedro Pimenta

Of course I will. But learning a language is not a quick thing and learning a minimum doesn't enable me to read entire posts.

Collapse
 
gregfletcher profile image
Greg Fletcher

I agree.

In my websites I use the user's chosen language. Not applicable to everything but makes sense in a lot of situations

Collapse
 
xeetzer profile image
xeetzer

I live in Switzerland and I speak french, which is totally normal as I live in the french speaking part. And yet almost every site display itself in german and I have to change it every time. It's seriously tiring :/

Some comments may only be visible to logged-in visitors. Sign in to view all comments.