Live data from Hacker News

Don't guess my language

vitonsky.net

51–60 of 392 posts

Re: Don't guess my language

#51
When we added translation features to our news site I went down this rabbit hole and wholly agree with the author. I checked what others were doing and very often there was this ip lookup happening, and then a redirect or other unnecessary behavior.

In our case, less is more. We decided to not do any of that, and were a bit paranoid that maybe we were going against a 'best practice' somehow?

All we do is look at navigator.language to get the language code:

   const userLanguage = navigator.language.split('-')[0]
and if we support that language then we will change the "Translate" button label to that language and default behavior to shortcut to that language version (you can still get the full list).

Thats it. Keep it simple.

Example: https://restofworld.org/2024/filipino-ai-chatbot-launches-20...

(translation UI in the byline area, under lead image)

Re: Don't guess my language

#52
post #16
post #11

And also make it easy on the site to change languages. Just because my OS is in US English, doesn't mean that I don't prefer certain sites to be in other languages when I choose to. Many of us are multilingual.

That should not be the business of the site, but of the browser. It is precisely what Accept-Language is for. The site should respect the header, allowing circumvention should be a very low accessibility priority.

The site should respect explicit user actions. A get request to a /en/ domain, or a button click to a language icon should result changing to that language. Respecting implicit preferences that are more likely than not be just plain wrong anyways should be a very low priority, ideally shouldn't be done at all.

Re: Don't guess my language

#53
post #30
post #13

Earlier quoted context omitted.

MacOS has this feature under Settings -> General -> Language & Region -> Preferred Languages. Here you can have an ordered list of languages you wish apps and websites (I _think_ only works for Safari) to use. I don't know how widespread this is in other OS'es or browsers.

That's just the standard Accept-Language header, not unique to Safari or macOS at all. It's up to the server to interpret and respond to the header, and they mostly don't do what gp wants, i.e. they usually serve the translated language with a higher q rather than the original language even if it's in the list (and it's mostly ignored anyway in favor of geoip/manual region/language picker).

It is not the accept-languages header - it affects the accept-languages header. Like the parent said, it is also used for apps (which includes your browser's UI).

Re: Don't guess my language

#54
post #23

I also hate the youtube "feature" that translates the titles of videos to your setting's language. This is so annoying. I can understand English and don't need these automatic translations.

Can't recommend "DeArrow" browser extension enough. YouTube is a miserable experience without it (and its sister extension SponsorBlock).

Re: Don't guess my language

#55
post #10
post #8

> You don’t override screen resolution or color scheme with your own guess They absolutely do lol. Like it or not, people like you are outnumbered by people who set their Accept-Language header wrong and don't know how to fix it. Those people probably buy more too (or at least buy more that shows up in tracking, since you sound like the kind of person who disables cookies etc. too).

> people like you are outnumbered by people who set their Accept-Language header wrong and don't know how to fix it Is this actually something that you can back up with data, or are you just guessing? I find it hard to imagine that would be the case, considering this header generally gets populated by the user's system locale/language.

Actually, yes. Google and Facebook invests in translation significantly more than Microsoft in languages in Africa and Asia (to the point that you cannot set Windows do not have that language in question), for example, the various non-colonial languages in the African continent. In those countries, the computer is set to English/French because not of practicality but of significantly broken/no translation by Microsoft.

Re: Don't guess my language

#56
post #23

I also hate the youtube "feature" that translates the titles of videos to your setting's language. This is so annoying. I can understand English and don't need these automatic translations.

Hear! Hear! It enrages me. They also automatically turn the subtitles ON, making you constantly have to disable them. There is no way for multilingual users to add a list of the languages they understand, which is an insane limitation that's been driving me crazy for years at this point. Wtf are they even working on at youtube's HQ? Making video thumbnails larger still?

Re: Don't guess my language

#57
post #23

I also hate the youtube "feature" that translates the titles of videos to your setting's language. This is so annoying. I can understand English and don't need these automatic translations.

I don't even get the point of that. If I need a translation of the title, I won't be able to watch the video anyways. At least ot makes some sense with the horribly auto-translated videos now, but they had the title translation for a long time while the video was still the original language.

Re: Don't guess my language

#58
post #21

I have told the story here before, but I built a neat little system to parse Accept-Language weighing the users priorities and using the closest thing we have on offer to the users preferences. As an example, we have a Brazilian Portuguese translation but not Portugal Portuguese, so we would offer the prior to users requesting the latter for instance unless they had a lower priority but more exact match. From my tech…

Yes! I still want to default to accept-language, but asking is key. What is your pattern for giving the user an option? I like this article in that it rejects icons, but I don’t like how they arrive at one language for multiple regions https://usersnap.com/blog/design-language-switch/

We literally just have a box that pops up with " ()" in each of the native languages. It gets saved to a long lived cookie rather than the user's account for some business reasons.

Re: Don't guess my language

#59

> Every browser sends an Accept-Language header. It tells you what language the user prefers, not based on location, not based on IP, based on their OS or browser config. And yes, users can tweak it if they care enough. This is also a broken assumption. First, Accept-Language is an ordered list, and most daily-multilingual people don't have an absolute order of preference, and more a topical list of preferences. If I…

> First, Accept-Language is an ordered list, and most daily-multilingual people don't have an absolute order of preference, and more a topical list of preferences.

Technically Accept-Language allows you to specify a "quality value"/weight for each language... https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/...

IMO there is a lot of improvements that can be made by both the browser and websites:

Websites should probably allow users to override the browser-requested language. But browsers should also allow users to choose between "Site default", "Request system default language", "Request English", "Request Chinese", "Request Spanish", etc. on a per site basis.

Most optimally however: sites should expose a list of supported languages, maybe in the manifest.json: https://developer.mozilla.org/en-US/docs/Web/Progressive_web... Format would be something like: `Map>`

Language selection should be done on the client side, not on the server.

Re: Don't guess my language

#60
post #18
post #2

I really wish for a language setting that says: If the original text is in one of the following languages, use the original text. I might not be equally fluent in all of those languages, but reading the original text is better than reading a translation most of the time.

You’re in luck! https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/... I wrote about it once; https://dijit.svbtle.com/trusting-the-user-they-know-what-la... Outlook web actually respects this, which is refreshing.

Unfortunately, that just specifies which languages you prefer, regardless of what the original language is.

I speak Dutch and English, but have English set as my preferred language, because most of the time that multiple languages are available, that is the original language. However, sometimes I'll be visiting a Dutch site that has a (usually badly-)translated English version available, and I'd rather get the Dutch version.

Post reply on HN