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

Oldest comments (54)

Collapse
 
bayuangora profile image
Bayu Angora

Agree. I don't use html lang anymore since migrate my website into static.

Collapse
 
ajimix profile image
Adria Jimenez

Yes, even worse the websites that use outdated IP geolocation databases and they think I'm located in different countries than where I'm really are 😩

Collapse
 
opshack profile image
Pooria A

Wished Facebook could understand this.

Collapse
 
bigi profile image
Bigi Lui

From a practical UX standpoint I agree with you; but here's a counterpoint.

I actually somewhat enjoyed it when I traveled to Europe (say, France) and I get on Google (whether on my laptop or at a hostel computer) and see it in French. I don't understand a word of French. But it makes the digital experience (Google) match the physical experience (e.g. street signs) and makes me feel more immersed in my travel. It's like "Hey, I'm in France now, I need to learn some French words."

Collapse
 
bitdweller profile image
Pedro Pimenta • Edited

Yes but I feel like that should be an option and it is not most cases. When I first moved to Spain, I changed my laptop to Spanish and when I was in France I put my mobile phone in French. But because I know something of that language. If I go to Russia... I won't be ableto even click anything :)

Collapse
 
bengreenberg profile image
Ben Greenberg

I see what you're saying, but it quickly loses its romanticism once you permanently move to a country where you are not fluent in the primary language and you have to do that every single day countless times a day. :)

Even if we strive to learn the native language, as we should if we are living there full-time, sometimes (often) you want to just get the info on the net you need quickly. Your whole life and every second in it doesn't need to be a language lesson.

Collapse
 
thiagomgd profile image
Thiago Margarida

Also, if you are logged on Google, let's say, and you want that immersion, you can just change your google settings to French. But while your settings are to English, why disrespect it?

Collapse
 
enlguy profile image
enlguy

This, almost exactly what my thoughts are.

Collapse
 
thaiiceland profile image
Kjarri-thaiiceland • Edited

Think if it was the other ways around, if it was your device that would change the system language every time you travel to another country, and image that you will travel to some country in Asia. How romantic would that be?
How will you be able to find Settings and change language to your prefer.
For me, I hate when I go to website and it displays it content in something that I don't understand and there is Nothing in English for you to be able to change the language. The only way is to close that website and sometimes this is very important website that you need to use....
If this was the default behavior on Android or IOS, then these devices would be totally useless when traveling.

Collapse
 
vlasales profile image
Vlastimil Pospichal

What is object navigator?

Collapse
 
bitdweller profile image
Pedro Pimenta

A special object in the browser: developer.mozilla.org/en-US/docs/W...

Collapse
 
aravindet profile image
Aravind Ravi Sulekha

Some websites are still generated on the server, so it might be helpful to mention the Accept-Language HTTP request header. developer.mozilla.org/en-US/docs/W...

Collapse
 
bitdweller profile image
Pedro Pimenta

Oh definitely. I just meant this post as an idea or concept. In the end I added that JS snippet because that's my area and it's how they're mostly done :)

Collapse
 
lampewebdev profile image
Michael "lampe" Lazarski

Yes please stop that!
My system language is English.
I can speak German, English, polish and a little bit of Russian.
But right now I live in Lithuania and I don't speak it.
It is not like any of the other languages and I often can not find the language switch
Because it is written out in words.
I also travel because of my job and yeah try to find that language switch in idk Chinese...

Collapse
 
sargalias profile image
Spyros Argalias

I agree that setting the language based on browser preferences is better than based on location. If you think about it from the user's point of view and the example you described, it makes perfect sense.

A step better than that is to have the language be part of the URL + provide a language option on your website. This is what Google recommends in Managing multi-regional sites. E.g. example.com/en/, or example.com/fr/. Again this makes sense from the user's point of view. If a friend is using your computer and they want to change language, they don't have to mess with browser settings.

Collapse
 
bitdweller profile image
Pedro Pimenta

Of course, this should always be an option. But what gets on my nerves is deciding defaults based on location.

Collapse
 
hdv profile image
Hussein Duvigneau

Even worse is when you manually fix the language in the URL, but the site thinks it knows better and just changes it back based on your location.

Thread Thread
 
sargalias profile image
Spyros Argalias

OMG, I actually laughed when I read your comment... That's quite bad...

Thread Thread
 
hdv profile image
Hussein Duvigneau • Edited

It's especially bad here in Switzerland, since the country has 4 official languages, some sites will force either French or German onto you without letting you switch to the other. Newsflash for those devs: Just because Switzerland has 4 languages doesn't mean every citizen can speak all four of them fluently. Especially us English-speaking immigrants who can't speak any of them :P

Of course it isn't just language. Ubisoft forces currency based on your location (Steam doesn't). Ikea even forces you to make a different account per locale - I get why this might be the easiest solution for the devs, but I'm sure with a bit of effort this doesn't need to be the case.

Collapse
 
sargalias profile image
Spyros Argalias

Agreed.

Collapse
 
bengreenberg profile image
Ben Greenberg

This post is one I can deeply relate to! I speak the language of the country I live in, but not natively, and while I enjoy continuing to improve and learn, not every moment on the Internet needs to be a lesson in linguistics! My browser is set to English as its language, and that should be a big enough clue to a site. Thanks for posting!

Collapse
 
markosaric profile image
Marko Saric

Completely agree! I run ProtonVPN pretty much at all times and they have the option to simply connect to the fastest server. Often it happens that the fastest server is from a country I don't speak the language to so I hate when sites automatically show me that language. I understand the idea behind it but there are better ways of doing this.

Collapse
 
shane profile image
Shane McGowan

My favorite is Microsoft defaulting their website to Irish if you're in Ireland. And the fact they translated the whole thing is amazing. Not even 1% of the population could read the site like that 💔

Collapse
 
mehdico profile image
Mehdi Mousavi

One of my main problems when I use a VPN !

Collapse
 
timvisee profile image
Tim Visée

The great thing is that browsers even commonly provide the users preferred language in request headers, so you don't even have to use JavaScript: developer.mozilla.org/en-US/docs/W...

Collapse
 
sergix profile image
Peyton McGinnis
Collapse
 
bitdweller profile image
Pedro Pimenta

Well, I put it there myself :) But it did stay on the front page for many hours and generated 263 comments, for which I'm very proud :)

Collapse
 
sergix profile image
Peyton McGinnis

Ahh, I should've recognized the username. No shame though! It's been one of the top posts over the past day with around 520 points, which is definitely an accomplishment for Hacker News. 👏🏼

Collapse
 
dev0x0 profile image
Mohamed El Bahja

When I created my LinkedIn account, I don't know how they set my account primary language to french based on my location, but I never used french and my browser is English and my Accept-Language HTTP header value is en, when I contacted them they say I not possible to change the primary language to English, the only solution is to delete the account and create new one (with US IP address)!

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