TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Accept my accept-language

111 点作者 hc5大约 11 年前

17 条评论

Udo大约 11 年前
Pretty much every major site will completely ignore not only your browser&#x27;s language settings but also onsite user account settings and other desperate attempts at selecting the language. The only thing that matters is your IP address.<p>For example, accessing Google: my browser is set to accept English only. I&#x27;m entering the English URL. In my account settings I periodically reset everything I can find to English (settings apparently decay, too). Google <i>knows</i> I want the English version. Yet, they still give me the interface in whatever language my IP address comes from. And not only the UI, search results as well.<p>Recently it&#x27;s gotten even worse than that: Google figured out I&#x27;m actually German, so they start defaulting to German more often now - ignoring everything else. At least with the IP address-based routing it was impersonal.<p>I happened to be in Sweden when I linked my Facebook calendar to my Google calendar. Ever since that day, my friends&#x27; birthdays are given to me in Swedish. Facebook <i>knows</i> I want English, yet for some reason this is how it&#x27;s got to be.<p>The same abuse is apparently considered best practice at new startups as well: recently I was testing a browser game for an acquaintance who&#x27;s on their development team. Because I was in Portugal at the time, I of course got the site in Portuguese. Manually switching that to English, the game still started up in Portuguese. It&#x27;s been doing that ever since. Every email I get from that company is in Portuguese, too, even though I tried everything I could to set my language to English.<p>It&#x27;s a source of endless frustration, maybe even a hostile act. They&#x27;re effectively saying &quot;<i>Your choices don&#x27;t matter, we know what&#x27;s best for you. You&#x27;re from country X, so you _must_ speak Xish. People are on the internet to enjoy regional separation. Really, it&#x27;s best.</i>&quot;
评论 #7409200 未加载
评论 #7409175 未加载
评论 #7410504 未加载
rwg大约 11 年前
You probably want something like &quot;en-US,en;q=0.9,ko;q=0.8&quot;. (Note the addition of &quot;en&quot; between &quot;en-US&quot; and &quot;ko&quot;.) Some quick testing with Firefox, which lets you directly alter the Accept-Language: header in requests in about:config, shows that fedoraproject.org has &quot;en&quot; versions of resources but not &quot;en-US&quot; versions. Since your Accept-Language: header only lists &quot;en-US&quot;, &quot;ko&quot; ends up being selected.<p><i>EDIT:</i> I just noticed your guesses at the bottom of the post. Your second guess is correct. See §14.4 of RFC 2616:<p><i>As an example, users might assume that on selecting &quot;en-gb&quot;, they will be served any kind of English document if British English is not available. A user agent might suggest in such a case to add &quot;en&quot; to get the best matching behavior.</i>
delroth大约 11 年前
I just fixed dolphin-emu.org, this was a bug in our code that would not detect en-US as being &quot;compatible&quot; with en. See <a href="https://github.com/dolphin-emu/www/commit/ddef974c6f601bc2dbbcc499c8990f4dd074615f" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dolphin-emu&#x2F;www&#x2F;commit&#x2F;ddef974c6f601bc2db...</a><p>As a French guy leaving in the German part of Switzerland with Accept-Language configured to get English content, I&#x27;m kind of ashamed to have that kind of bug in my language detection code. I&#x27;m always complaining about other websites language detection, looks like I should have looked at my own code first!
评论 #7410395 未加载
评论 #7409342 未加载
crazygringo大约 11 年前
Language choices are a mess. There can easily (and often) be conflicting data based on:<p>- accept-language header<p>- URL that includes language&#x2F;region codes as a subdomain or part of the path<p>- language preferences set in a cookie or account<p>- IP region detection<p>In the end, any website is trying to provide the right language most often for their users, and there are no easy answers. When I access webmail from an Internet cafe in China, I don&#x27;t want the interface popping up in Chinese just because the browser&#x27;s accept-language is configured for Chinese. Fortunately, it doesn&#x27;t.<p>Most web users have never even heard of accept-language, it&#x27;s just automatically configured by whatever language their browser was installed in, which isn&#x27;t always the language you want to be browsing in. (E.g. you bought your laptop overseas because it was cheaper, so it runs in English instead of your own language.) It&#x27;s not a surprise that IP address detection provides the best default experience most of the time, which can then be overridden by URL or user choice, and that accept-language is fairly irrelevant.
评论 #7409914 未加载
raving-richard大约 11 年前
Google is^H^Hwas* really bloody annoying when it comes to this. English (en-us and en) is the only language in my accept header. When I lived in Geneva though, Google always used to serve me pages in German (presumably Swiss-German). Gee, that&#x27;s logical. (Geneva is a mainly French speaking city, though over 40% of the population is non-Swiss.)<p>Where I live now is another French speaking area. I just checked and it seems they are no longer serving French pages to me. But they were even just one year ago. (I don&#x27;t use Google by default, so I don&#x27;t know when they changed.)<p>Admittedly, that was an issue with geo-detecting rather than the website having bad language detection.<p>* They seemed to have stopped.<p>Air France is (though they have many faults) actually alright at detecting my language. And mostly gives me English pages...
评论 #7408921 未加载
评论 #7409788 未加载
评论 #7408709 未加载
评论 #7408731 未加载
评论 #7408644 未加载
darklajid大约 11 年前
My accept header only contains en-US and en. I tend to get served German content (and Google&#x27;s especially bad about this).<p>Please, I hope someone hears your complains and starts fixing things. That issue is highly annoying..
评论 #7408989 未加载
评论 #7408900 未加载
jtokoph大约 11 年前
&gt; 1. the default quality value is being parsed wrong, and English is being assigned q=0 instead of q=1 or<p>&gt; 2. en-US doesn&#x27;t match en and is being bypassed<p>Or: 3. They are simply checking your IP address and not looking at your header at all.
评论 #7408545 未加载
评论 #7408517 未加载
junto大约 11 年前
I have blogged about this several times. Google are one of the worst offenders. I&#x27;m not sure if it is insular non-travelled US developers with a deep love of IP-to-geolication databases, or an anally retentive legal department, but it really sucks as a user experience.<p>From an advertising perspective this is a major market that is being overlooked, because guess what, I don&#x27;t look at ads that much, but you can bet your bottom advertising dollar that I&#x27;m definitely not going to read it in a language that isn&#x27;t my mother tongue.<p>IP address != language preference<p>It is about time that developers got that through their thick skulls.<p>Finally, over here in Europe we can live in whichever EU country we want to. This means that we can move countries easily. I&#x27;ve already been in four of them. I don&#x27;t think I&#x27;m an edge case by any means. People migrate.
midas007大约 11 年前
I&#x27;m working on locale stuff for a Rails app right now (just updated the i18n_data in fact).<p>The assumption will be that country is mostly orthognal to language b&#x2F;c people are übermobile. Further, that the dialect of the language should not force assumptions of other preferences... only autodiscover initial settings as close to desired as possible. (Fuck, why isn&#x27;t there a standard for this common, hard-to-manage shit the OS already knows.)<p>i18n is taking up tons of time to get (mostly) right, but I believe it&#x27;s one of those things not to botch because it&#x27;s such a huge signal to everything else about your app.<p>If I want to be the most obscure hipster paying in Lesotho Loti, read Catalonian, have a &quot;,&quot; for thousands separator and use UTC tz, by Flying Spaghetti Monster that&#x27;s what it&#x27;s gonna allow.
评论 #7408646 未加载
pytrin大约 11 年前
Those sites are not relying on accept-language, but rather on IP geolocation to select the default language. I sometimes use a non-US proxy when I&#x27;m feeling vigilant, and Google always uses the IP of the proxy to determine what language to serve me (even though my browser accept-language hasn&#x27;t changed).
nemetroid大约 11 年前
I&#x27;m running an English version of Windows 7 in Sweden. The accept-language headers in each of my installed browsers are:<p>* IE9: sv-SE<p>* Firefox: en,sv;q=0.5<p>* Chrome: en-US,en;q=0.8,sv;q=0.6<p>I&#x27;m going to go ahead and suggest that the reason English comes before Swedish is due to my system language, and that Swedish otherwise would come first. The &quot;users will have the wrong settings&quot; argument seems moot to me.
评论 #7409573 未加载
gioele大约 11 年前
To avoid such problems in Rack&#x2F;Rails Ruby project I suggest the rack-i18n_best_langs gem (regardless of the name, it does not depend on the i18n gem) I wrote:<p><pre><code> https:&#x2F;&#x2F;github.com&#x2F;gioele&#x2F;rack-i18n_best_langs </code></pre> &gt; Differently from other similar Rack middleware components, rack-i18n_best_langs returns a list of languages in order of guessed importance, not a single language.<p>&gt; Language discovery is done using three clues:<p>&gt; * the presences of language tags in paths (e.g. &#x2F;service&#x2F;warranty&#x2F;ita),<p>&gt; * the content of the HTTP Accept-Language header,<p>&gt; * the content of the rack.i18n_best_langs cookie when set.
Aldo_MX大约 11 年前
Unrelated with the accept-language issue, but somehow related:<p>I needed to create a yahoo account, and I registered it selecting the kimo.com domain (kimo.com is a Chinese domain owned by yahoo). Since the first moment I set my language preferences to English.<p>No matter which yahoo service I&#x27;m visiting, I always get welcomed by <i>at least the login prompt</i> in Chinese, I can&#x27;t really complain, because I was the one who looked for a rare domain, but it&#x27;s an annoyance for me, because yahoo assumes that I understand Chinese because of the domain.
nraynaud大约 11 年前
There is also the problem of getting the original content, I speak 3 langages, I intend to read the original source if it&#x27;s one of those language. I don&#x27;t want unpaid-intern translation.<p>MS C# documentation deserve a special kind of hell, because they detected I reverted the language to english ; and now they present me a special translation mode of their freaking doc where there are huge tooltip texts everywhere.
评论 #7409994 未加载
pornel大约 11 年前
Sorry, when I implement language negotiation I interpret &quot;en-US&quot; as lack of preference.<p>The problem is that en-US is the default and I can&#x27;t tell difference between user not setting language and user choosing en-US.<p>Add &quot;en&quot; or even &quot;en-GB&quot; to your Accept-Language header.
评论 #7409618 未加载
petercooper大约 11 年前
accept-language is like any of 1000 other idealistic parts of Internet specs that has good intentions but is so poorly used (or misused) that almost no-one implements it correctly, instead simply doing the simplest thing that works best for 99% of the audience.
raverbashing大约 11 年前
If I access Google using and European IP it will show the Google page for the Country I am in, regardless of my accept-language<p>(I don&#x27;t have an accept-language for Dutch, Italian, German, French but in all these cases I was shown the local page)