Live data from Hacker News

Who uses Accept-Language header?

serpapi.com

21–30 of 71 posts

Re: Who uses Accept-Language header?

#21

Earlier quoted context omitted.

Indeed, google never behaves for me, always hands me language localized to my ip, even though my Accept-Language contains "en-US,en;q=0.9" (the local language is my native one, but i find using services or software that are originally in English translated to my (non-PIE) language awful, even anger-inducing). For search i have had &hl=en added to the search parameters since forever.

What works surprisingly often is setting language to en-UK instead. Apparently many sites consider en-US to be some default that they can safely ignore, but en-UK to be a deliberate choice. Nowadays I use that not just for the browser, but for my phone and computer too.

I can say that it doesn't work on Google Docs, which uses the IP address's language^, even though my language is set to en-UK. Unless you're logged in, but I often have to use incognito because of another misfeature which is that Google will dox you to other editors if you access a public Google doc while logged in. Googlers reading this comment: please fix this!

^ I wonder how this works in places like Switzerland and Belgium that have more than one language. The notion that IP addresses can be mapped to languages needs to die.

Re: Who uses Accept-Language header?

#22
post #2

There are many many cases when you can’t determine user’s language by location only (immigrants, VPNs, business trips, multinational corporations, countries where people speak multiple languages, etc). If you do any effort in localization, you should recognize Accept-Language. If unsure, you should ask the user for their preferred language directly. Inferring the language by location is not acceptable. Here in Switze…

At work we have it implemented as follows: 1. Check if there is a language cookie set previously 2. If no cookie, check if the Accept-Language is present and contains one of the supported locales 3. If no Accept-Language matches, use the fallback application language Not that hard to implement, except perhaps parsing the Accept-Language preferences with their quality value can be cumbersome.

> Not that hard to implement, except perhaps parsing the Accept-Language preferences with their quality value can be cumbersome.

Many web frameworks provide a tool for parsing these for you. If yours doesn't (or you're not using one) you may be able to find a package that does. Some will also do the matching for you, so you can pass it a list of languages you can support alongside the Accept-Language string and it will pick the best option that's found in both.

For example, here's the documentation for such a method in the excellent Nette PHP framework that I've been using where I can lately: https://doc.nette.org/en/http/request#toc-detectlanguage

But I've also used this stand-alone package: https://packagist.org/packages/willdurand/negotiation

Re: Who uses Accept-Language header?

#23

There are two situations that I hate: 1. I have a different IP than usual, so all the sites change to that country - including language, news and search results(Google), etc, even though my browser sets a list of Accept-Language options. It's still me, I know you track me, so why? 2. Changing a multi-language website to a different country, also changes the language to that country, even though by browser sends an Ac…

1.b. When somehow they identify you’ve change IPs the first time, and now that you are home, there’s still some sticky session that doesn’t get cleared without purging all cookies for the domain.

Re: Who uses Accept-Language header?

#24
Even Accept-Language headers aren't really a particularly good solution. I might prefer some sites in Danish, but others I'd like to have en English. Unless browsers allow you to set language on a per site basis, we still aren't really capturing the nuances of language preference.

Accept-Language could be a pretty good indicator of a persons language skills, but it's just to far into the browsers settings to be something that a normal user would adjust. I can see why checking the domain is quicker and perhaps more inline with a persons intent, even if it is ignoring travelling.

We where trying to book a table at a restaurant, it's part of a fairly large chain. We where in Sweden, but the chain also operates in Denmark, so we know that they have a Danish version of their website and ordering app, you just can't use the Danish language when you are in Sweden. You can get English for some reason, but not the Danish version. That to me seem like a missed opportunity.

Re: Who uses Accept-Language header?

#25

Earlier quoted context omitted.

> To answer the question, yes, normally you would have some kind of manual switcher that sets the cookie. Please don’t use flags for this, because flags indicate countries, not languages. Don’t make a Russian-speaking Ukrainian seek out the Russian flag, and don’t make an English-speaking Irish person seek out the Union Flag. Yes, why make things easy. :-) Controversial opinion: Flags are great as a visual aid, short…

Better yet: Offer en_CA, en_GB, en_IE, and en_US, with appropriate flags. (Bonus point for fr_CA with the CA-QC flag)

But then where's the flag for Liberia and Belize and Singapore? What if I'm in Indonesia and you don't offer an Indonesian option but I know enough English to get by - what country's flag should I click?

Just don't use flags, man. It's ridiculous that this is even still a discussion.

Re: Who uses Accept-Language header?

#26
> Interestingly, Google does respect the Accept-Language header.

Google knows I use/want English. It knows this because I'm logged-in and have set my preferences, but also because of that Accept-Language header my browser sends in every single request. Yet for years, perhaps because I am 20km from Germany, it has assumed I would always prefer German when doing social sign-in.

Google may occasionally glance at Accept-Language, but it does not respect it. It even demotes my own logged-in preferences below a guess based on my location.

When there are no other indicators, fine, guess my language from my location, but otherwise location != language. But I know for fact that my browser is sending out Accept-Language headers in a convenient format that will tell you all you need to know.

Re: Who uses Accept-Language header?

#27

Earlier quoted context omitted.

Indeed, google never behaves for me, always hands me language localized to my ip, even though my Accept-Language contains "en-US,en;q=0.9" (the local language is my native one, but i find using services or software that are originally in English translated to my (non-PIE) language awful, even anger-inducing). For search i have had &hl=en added to the search parameters since forever.

What works surprisingly often is setting language to en-UK instead. Apparently many sites consider en-US to be some default that they can safely ignore, but en-UK to be a deliberate choice. Nowadays I use that not just for the browser, but for my phone and computer too.

I had my language set to en-NZ when I lived in Indonesia; definitely had Google serve pages in Indonesian to me (and double frustratingly, with US-style dates).

Re: Who uses Accept-Language header?

#28
post #2

There are many many cases when you can’t determine user’s language by location only (immigrants, VPNs, business trips, multinational corporations, countries where people speak multiple languages, etc). If you do any effort in localization, you should recognize Accept-Language. If unsure, you should ask the user for their preferred language directly. Inferring the language by location is not acceptable. Here in Switze…

At work we have it implemented as follows: 1. Check if there is a language cookie set previously 2. If no cookie, check if the Accept-Language is present and contains one of the supported locales 3. If no Accept-Language matches, use the fallback application language Not that hard to implement, except perhaps parsing the Accept-Language preferences with their quality value can be cumbersome.

`Accept-Language` contain both language and locale. Depending on your app you might have supported languages or language/locale combinations. When there's no exact match after step 2, you'll want to do a partial-match on only the language.

Re: Who uses Accept-Language header?

#29

Earlier quoted context omitted.

It is a part of browser's settings (for Chrome and Firefox at least), and it is default to system's default language I think.

You’re talking about the Accept-Language header . They are asking about the cookie. To answer the question, yes, normally you would have some kind of manual switcher that sets the cookie. Please don’t use flags for this, because flags indicate countries, not languages. Don’t make a Russian-speaking Ukrainian seek out the Russian flag, and don’t make an English-speaking Irish person seek out the Union Flag.

[deleted]
Post reply on HN