Stop setting the language of your website based on user location

bitdweller profile image Pedro Pimenta ・1 min read

Please, stop!


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,

Posted on by:

bitdweller profile

Pedro Pimenta


Front-end developer, graphic designer and human being.


markdown guide

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...


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.


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."


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.


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?


Search engine are a special case because it's very important for them to be location aware. I mean if you are in France and search for the best place to buy croissant it's logical to have results according to where you are and not which language you speak.

But for the rest of websites , where the results does not really depends of your location , there is no point in not using the browser language.


Location-aware impacting results is a good thing, but I'd argue towards results and translations being separated.


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 :)


The worst offenders are the

...sites that don't let you switch language at all after they decided they know what you want. For example, Apple removed the /th/en option from their website at one point, so now it's always in Thai, with no option for switching. I read Thai ok, but I'm much slower than with English and generally prefer not using it for shopping when given a choice.


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


Thanks! Anyway, there are some other sites where you definitely can't switch, but maybe I should just send you my list to double check 😉


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...


Wished Facebook could understand this.


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!


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.


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


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.

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

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.


Living for almost 5 years in different countries(Netherlands, Switzerland), main language of which I don't speak, at the beginning I had same idea. But later, it came to my mind that there is a lot of different situations, in which that's not possible.
If we take local online shops - they have versions in their language and translating it in another language usually doesn't make economical sense.
If we talk about news site, no one is gonna hire multiple journalists to produce news in multiple languages.
If we talk about big international shops(apple, ikea), those who already have let's say English version available. Turns out is not that easy either. There is a lot of content that is country specific, even on international shop sites. And let's take example of Netherlands. They prepare Ikea's local content to what make sense in Dutch. Now should they prepare content in English as well? Or should they just show US/UK version, which often won't make sense because of Dutch specific market?

So, in all cases, the problem is that it requires additional work to prepare content for local market, often without economical sense. If you prepare on Netherlands version of Ikea, English version, should you prepare Chinese as well?
Why English would have more priority? And so on.
Besides, these 3 categories what other sites are bothering you, doing that?


Your point is valid and I wouldn't complain about those cases and I don't think someone else will. It's understood that different regions have different products. That would be an impossible feat.

I'm talking mostly about online services and some blogs. The website that sparked this post specifically was this: matterport.com. It opened in english, I was already reading it and then there was a refresh and everything turned to german. Apart from the bad UX of waiting for a reload (*1), there's no content change. It's the same website, the same content. OK, you have different phone numbers for contact but that can be on its own page.

But there are worst offenders. For example, GOG.com, a video games online store/service that I really like, changes the language and then saves it to the browser. I opened it in France, and although I've have for years browsed in the English version, it's now in French, I have to manually change it. It makes no sense, when they can fetch the browser's language.

Google does the same. Google is 100% the same (apart from a few country-specific services, but that's not what this is about). I understand if your search results are relative to where I am, but the interface should be in my language of choice (smartly fetched from my browser/machine preferences). And they can fetch my region to hide the products that they don't offer in my region, in this case, where 98% of it is available globally.

*1: I've built websites where a language reload was important. The first thing we did was load that specific JS that checked the browser's language and then reloaded, which was super fast and there was no repaint


ok, fair enough.

"And they can fetch my region to hide the products that they don't offer in my region, in this case, where 98% of it is available globally." - what about products that are available in your region, but not in others? should whole site be in english and some products in ducth(because they're available only Netherlands and translating in every other world doesn't make sense?)

but I learnt to live with google chrome and translation of the site.

the bigger problem I have, to be honest is when a platform like PlayStation, offer their store only in local language(like your bank account) and to make it worse, you can't change your country after registration. I had account in Netherlands and now I have either option to continue using dutch version(even I'm not living there anymore) or to lose all my previous purchases and start from scratch :D

what about products that are available in your region, but not in others? should whole site be in english and some products in ducth(because they're available only Netherlands and translating in every other world doesn't make sense?)

Yes, exactly. The page and info for that product can be on the language that it's available in (in this case, decided by region). But the overall UI and navigation should maintain your language, so you can still navigate and get out of there.


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 😩


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...


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 :)


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)!


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...


Although some countries / areas are welcoming to people who don't speak the language, you will have an improved user experience in a country if you learn a minimum of their language.

Btw you wrote "I'm currently living in Germany for a while" yet your location on the right says "Barcelona".


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.


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 :)


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. 👏🏼


I am kind of the exact opposite...
I also live in Germany. I speak German rather well, as it is my mother tongue. What I do not want, is my interfaces in German as it makes googling for problems so much harder and I do that more often than I should, probably.
So I deliberately set my OS language to English. For websites like BVG (Berlin public transport) I understand, that they are showing me the site in English. I click on "German" and I am fine. I have to do this every single time. This setting is not stored. So please (whoever this is reading) if you give your users the ability to choose a language, store that information indefinitely (or some equivalent).


Yes it's the same for me. I'm Portuguese but I'm fluent I English and I have my devices in English and I prefer English languages for UI, except if they're local services. But that is an exception, I don't feel it should be the default.


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.


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 :/


100% agree.

Mostly when you are Portuguese and the website śhows PT_BR.

The latest example for me, was Google Cloud Console, that while I have everything in my Google Account in English in started showing content in Brazilian. And I remember it was not that easy to find a way to change it :\


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 💔


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


One of my main problems when I use a VPN !


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


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


Couldn't agree more. A good example of premature optimization IMO.


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.


I agree.

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