
Ask HN: How do you detect user language in web sites - Ayesh
Hello HN,
I&#x27;m interested to hear how would you configured your web apps and web sites to detect visitor language.<p>I currently use the Accept-Language header, most of the browsers appear to just use `en-US` as the default. I am not sure if default installations in various countries have different default settings (for example `de-DE, de` if you download Firefox from Germany).<p>Second, I could use a small IPGeo database to determine the user country and map it to locale&#x2F;language, but I really don&#x27;t want to do it because it&#x27;s not very user-friendly to those who travel or simply prefer English.<p>I will of course have a language select list and save this preference, but I&#x27;m interested to hear how I can make it user-friendly and do some guess work for the user without being annoying to those who prefer English as opposed to the what my app _think_ based on the location.
======
Normille
We had a discussion about this kind of thing and associated pitfalls, a couple
of weeks back:

[https://news.ycombinator.com/item?id=23216502](https://news.ycombinator.com/item?id=23216502)

After the hassles I've had with Yandex Browser [as mentioned in the above] I'd
say; don't try and detect it. Let the user select their preferred language.

Or, if you really insist on trying to be clever by detecting user language
--for the love of all that's holy, give the user an easy way to change it if
[when!] you get it wrong!

Few things more annoying that a page which loads in the 'wrong' language and
then, even if you select the 'right' one, automatically reloads the wrong one
again, because the developer wanted to show off some fancy _" I know what you
want better than you do!"_ scripting.

~~~
zeeZ
Even worse, it redirects you to the landing page instead of the different
language version of the page you were just on.

It's so bad before even trying to look for a language toggle I see if I can
replace "de" with "en" in the URL somewhere, drop it altogether, or append a
"hl=en" query parameter.

------
Etheryte
As an expat living abroad, please don't do this. Your webpage doesn't know
better than the user's settings, there are few things more annoying than sites
that automatically redirect you to another subdomain based on your location.
Luckily, the right thing is the easy one in this case, simply add a language
picker to your site.

