For a long time I've been not happy with the behavior of Google in the cases below, and after accidentally noting that 80+ other people feel the same way (and 20+ people upvote the idea of Google bug report) I thought it's useful to tap into SO's wisdom on HTTP protocols and the web culture.
很长一段时间以来,我一直对谷歌在下面的案例中的行为不满意,并且在意外地注意到80多个其他人都有同样的感觉(并且有20多人赞成谷歌错误报告的想法)我觉得它很有用利用SO在HTTP协议和网络文化方面的智慧。
This behavior appears every time I go to a different country and access google.com
from my laptop or install a new browser. In many countries, including Vietnam, google automatically redirects to a localized version (e.g. google.com.vn), the one I can't actually read so I scan it in a desperate attempt to find Google.com in English link.
每次我访问其他国家/地区并从我的笔记本电脑访问google.com或安装新浏览器时,都会出现此问题。在包括越南在内的许多国家/地区,谷歌会自动重定向到本地化版本(例如google.com.vn),这是我实际上无法阅读的版本,所以我会在拼命尝试查找Google.com的英文链接中进行扫描。
The first time it happened I was puzzled and spent some time finding out what could be wrong with my request headers; as I expected, my Accept-Language
is always en-US
or something like en-US,ru;q=0.5
. Further tests with different IPs confirmed that they do IP geolocation, even when you are logged in. Later I learned there is a language query ?hl=...
, but still.
它第一次发生时我很困惑,花了一些时间找出我的请求标题可能出错的地方;正如我所料,我的接受语言总是在美国或类似于en-US,ru; q = 0.5。使用不同IP的进一步测试证实,即使您已登录,它们也会进行IP地理定位。后来我了解到有语言查询?hl = ...,但仍然如此。
So, my question would be: do you think this is reasonable and expected behavior, webculture-wise? Do other sites do it too? If you were to design a multilanguage site what would you do with a person who comes from .vn
IP but with en-US
language?
所以,我的问题是:你认为这是合理的和预期的行为吗,网络文化明智吗?其他网站也这样做吗?如果您要设计一个多语言网站,您会对来自.vn IP但使用en-US语言的人做些什么?
I imagine there are different approaches to IP geolocation:
我想有不同的IP地理定位方法:
-
contra: I think this is impolite: I tell you explicitly what I want, what's good about giving me something else?
反对:我认为这是不礼貌的:我明确告诉你我想要什么,给我一些其他的东西有什么好处?
-
pro: It could be that a person has just installed browser with the default language pack, without any idea about
Accept-*
headers, and still would prefer to see localized version of a website.亲:可能是一个人刚安装了默认语言包的浏览器,不知道Accept- *标题,仍然希望看到网站的本地化版本。
-
contra: And yet, non-techie people can easily change accept-language by installing a language pack. In fact, if you go to download Firefox, chances are you'll download the one in the language you want, with the accept-language header that respects your wishes.
contra:然而,非技术人员可以通过安装语言包轻松更改接受语言。事实上,如果你去下载Firefox,你很可能会用你想要的语言下载一个,使用符合你意愿的接受语言标题。
Note that I read the HTTP 1.1 specification from 1999 but they seem to omit the question of how much the Accept-Language
should be really taken into consideration.
请注意,我从1999年开始阅读HTTP 1.1规范,但它们似乎省略了应该如何真正考虑Accept-Language的问题。
I believe this question belongs to SO as a web-app design question. And I'm still thinking about filing a formal bug report (if I am correct that this behavior is far from web standards).
我相信这个问题属于SO作为网络应用程序设计问题。而且我还在考虑提交正式的错误报告(如果我说的话,这种行为远非网络标准)。
8 个解决方案
#1
I think there are really two separate issues at play here. Language and country. They most definitely are not the same thing. The HTTP spec explicitly defines the Accept-Language request-header field as language specifier, not a country specifier.
我认为这里有两个独立的问题。语言和国家。他们绝对不是一回事。 HTTP规范明确地将Accept-Language请求标头字段定义为语言说明符,而不是国家说明符。
For example: en-US refers to a specific language (the version of English spoken mostly in the United States), en-GB refers to another language (the version of English spoken mostly in the United Kingdom). This really has nothing to do with where you currently are in the world, it just defines what language is most acceptable to you when viewing a website. And that should be respected because even novice users should have a browser in their language which will by default send the correct request-header field.
例如:en-US是指特定语言(主要在美国使用的英语版本),en-GB是指另一种语言(主要在英国使用的英语版本)。这实际上与您目前在世界上的位置无关,它只是定义了您在查看网站时最容易接受的语言。这应该得到尊重,因为即使新手用户也应该使用他们语言的浏览器,默认情况下会发送正确的请求标头字段。
But that's not what sites traditionally use it as. Like another poster, I've noticed that sites equate language with country and tailor their site to that country's unique political restrictions/freedoms/the company's offerings there, not necessarily for the language. The example given was a company that doesn't sell a particular product in a particular country but does in others.
但这不是传统上使用它的网站。像另一张海报一样,我注意到网站将语言与国家等同,并将其网站定制为该国独特的政治限制/*/公司在那里的产品,而不一定是语言。给出的例子是一家公司不在特定国家销售特定产品,但在其他国家销售特定产品。
In the case of what products to display for different countries, geolocating the IP address would be better than making decisions based off the language but it still wouldn't be perfect. What if I'm in another country temporarily but want to order something and have it delivered back home? What if my IP address doesn't reflect where I physically am, it's not perfect?
在针对不同国家/地区展示哪些产品的情况下,对IP地址进行地理定位将比基于语言做出决策更好,但仍然不是完美的。如果我暂时在另一个国家,但想要订购并将其送回家,该怎么办?如果我的IP地址不能反映我的身体状况,那会怎么样?
Yes, things work correctly for most people most of the time. But why on Earth would you make it hard for people to get the site in the language that they ask for?? It's just bad UI design.
是的,大多数时候,大多数人都能正常工作。但是为什么在地球上你会让人们难以用他们要求的语言获取网站?这只是糟糕的UI设计。
#2
Although i understand and even share your frustration, there are some legit reasons to do that.
虽然我理解甚至分享你的沮丧,但有一些合理的理由这样做。
Many companies have sites tailored to each specific country. For example, because they don't sell all their products to every country, or because a law in a specific country put some specific obligation on their site (a line of product banned, a legal notice added, or whater, ...).
许多公司都有适合每个特定国家的网站。例如,因为他们不会将所有产品销售给每个国家,或者因为特定国家/地区的法律在其网站上放置了一些特定义务(禁止使用产品线,添加法律声明,或者更新,......) 。
Therefore, they will serve you the version tailored to the country you're in because that's supposed to be the most useful (it doesn't matter that company X is selling product Y in country Z if i'm not currently in country Z).
因此,他们将为您提供适合您所在国家/地区的版本,因为这应该是最有用的(如果我目前不在Z国家,公司X在Z国销售产品Y并不重要) 。
#3
Google is smart. I imagine they do what they do because for the majority of cases if you're in Vietnam you most likely want .vn
- we're technical people so we know all about accept-language and such, but the vast majority of people don't.
谷歌很聪明。我想他们会做他们做的事情,因为在大多数情况下,如果你在越南,你很可能想要.vn - 我们是技术人员,所以我们都知道所有接受语言等等,但绝大多数人都不喜欢吨。
That being said, I think one thing they could to at least be polite to the accept-language header, is to show some kind of notification (kind of like the banners that show in this website) saying something like "Looking for Google in English? Click here" if the header indicated they want english - while that may not work for Google (as they don't do it), I would certainly consider that if I was making a multilingual website.
话虽如此,我认为他们可以至少对接受语言标题有礼貌,就是要显示某种通知(有点像本网站上显示的横幅),说“用英语寻找谷歌” ?点击这里“如果标题表明他们想要英语 - 虽然这可能不适用于谷歌(因为他们不这样做),我当然会考虑如果我正在制作一个多语种网站。
#4
I'm betting that there are more people use software that doesn't properly utilize this HTTP header value than there are people who live in a country and don't speak/read the native tongue. That would explain Google's behavior.
我敢打赌,有更多人使用的软件没有正确使用这个HTTP标头值,而不是生活在一个国家并且不会说/读本土语言的人。这可以解释谷歌的行为。
#5
I share your frustration. I've been disappointed by a great number of sites. Most do IP-geolocation but obviously have no idea about the browser culture settings. Needless to say, the user location is an unreliable information source about which language and culture the user prefers. Especially in the times of globalization where peoples and cultures are highly mixed.
我分享你的沮丧。我对很多网站感到很失望。大多数人做IP地理定位,但显然不了解浏览器文化设置。不用说,用户位置是关于用户喜欢哪种语言和文化的不可靠信息源。特别是在人口和文化高度混合的全球化时代。
Note that I read the HTTP 1.1 specification from 1999 but they seem to omit the question of how much the Accept-Language should be really taken into consideration.
请注意,我从1999年开始阅读HTTP 1.1规范,但它们似乎省略了应该如何真正考虑Accept-Language的问题。
This setting is actively supported by modern browsers. There is no good reason not to take it into consideration. If the header is not present in the request, do geolocation, otherwise respect the user culture setting.
现代浏览器积极支持此设置。没有理由不考虑它。如果请求中不存在标头,请执行地理位置,否则请遵守用户区域设置。
#6
I'f from Latvia, I prefer English. Firefox sends en-US by default, IE sends lv-LV (even though it is English version) because of Windows regional settings. So accept-header is unreliable.
我来自拉脱维亚,我更喜欢英语。 Firefox默认发送en-US,因为Windows区域设置,IE发送lv-LV(即使它是英文版)。所以accept-header是不可靠的。
IMHO best way is to do both geolocation and accept-language check,
恕我直言最好的方法是做地理定位和接受语言检查,
if region and language matches => auto redirect if there is no match => serve your best guess and give user a choice (maybe top right corner of the screen is the best place for language switch as it is UI standard more or less) + remember that choice in a cookie
如果区域和语言匹配=> auto redirect如果没有匹配=>提供你最好的猜测并给用户一个选择(可能是屏幕的右上角是语言切换的最佳位置,因为它或多或少是UI标准)+记住在cookie中的选择
#7
I'm guessing that a significant percentage of people in non-English speaking countries use browsers that report Accept-language of English (perhaps because they use pirated English versions, who knows).
我猜测非英语国家的很大一部分人使用报告英语接受语言的浏览器(也许是因为他们使用的是盗版英语版本,谁知道)。
Most of them, aside from a vocal minority on a English-language programming web site :), would expect to see web sites in their own language, and the common folk don't care about HTTP specifications. This would make the Accept-language header essentially useless, a perfect example of how the real world != programmer fantasy world.
除了英语编程网站上的少数人之外,他们中的大多数人都希望看到自己语言的网站,普通人不关心HTTP规范。这会使Accept-language标题基本无用,这是现实世界!=程序员幻想世界的完美例子。
#8
I agree Google is misbehaving. I suspect this is a result of a structural over-optimization. If you put servers close to users, and your goal is insanely fast results, you're better off serving a single cache of search results in a single language, off of each local server cluster.
我同意谷歌行为不端。我怀疑这是结构过度优化的结果。如果您将服务器放在用户附近,并且您的目标是非常快速的结果,那么最好使用单一语言(每个本地服务器群集)提供单个搜索结果缓存。
That means when your IP comes in, it's not so much IP Geolocation as, which server cluster answered your request first. And that cluster nearest to you in Vietnam is optimized to serve pages in Vietnamese.
这意味着当您的IP进入时,IP地理位置并不是那么多,哪个服务器群集首先回答了您的请求。而在越南最接近你的群集被优化为用越南语提供页面。
I'm sure this is resolvable but I wouldn't be surprised if the design of that optimization makes it difficult for them to fix.
我确信这是可以解决的,但如果优化的设计使他们难以修复,我不会感到惊讶。
#1
I think there are really two separate issues at play here. Language and country. They most definitely are not the same thing. The HTTP spec explicitly defines the Accept-Language request-header field as language specifier, not a country specifier.
我认为这里有两个独立的问题。语言和国家。他们绝对不是一回事。 HTTP规范明确地将Accept-Language请求标头字段定义为语言说明符,而不是国家说明符。
For example: en-US refers to a specific language (the version of English spoken mostly in the United States), en-GB refers to another language (the version of English spoken mostly in the United Kingdom). This really has nothing to do with where you currently are in the world, it just defines what language is most acceptable to you when viewing a website. And that should be respected because even novice users should have a browser in their language which will by default send the correct request-header field.
例如:en-US是指特定语言(主要在美国使用的英语版本),en-GB是指另一种语言(主要在英国使用的英语版本)。这实际上与您目前在世界上的位置无关,它只是定义了您在查看网站时最容易接受的语言。这应该得到尊重,因为即使新手用户也应该使用他们语言的浏览器,默认情况下会发送正确的请求标头字段。
But that's not what sites traditionally use it as. Like another poster, I've noticed that sites equate language with country and tailor their site to that country's unique political restrictions/freedoms/the company's offerings there, not necessarily for the language. The example given was a company that doesn't sell a particular product in a particular country but does in others.
但这不是传统上使用它的网站。像另一张海报一样,我注意到网站将语言与国家等同,并将其网站定制为该国独特的政治限制/*/公司在那里的产品,而不一定是语言。给出的例子是一家公司不在特定国家销售特定产品,但在其他国家销售特定产品。
In the case of what products to display for different countries, geolocating the IP address would be better than making decisions based off the language but it still wouldn't be perfect. What if I'm in another country temporarily but want to order something and have it delivered back home? What if my IP address doesn't reflect where I physically am, it's not perfect?
在针对不同国家/地区展示哪些产品的情况下,对IP地址进行地理定位将比基于语言做出决策更好,但仍然不是完美的。如果我暂时在另一个国家,但想要订购并将其送回家,该怎么办?如果我的IP地址不能反映我的身体状况,那会怎么样?
Yes, things work correctly for most people most of the time. But why on Earth would you make it hard for people to get the site in the language that they ask for?? It's just bad UI design.
是的,大多数时候,大多数人都能正常工作。但是为什么在地球上你会让人们难以用他们要求的语言获取网站?这只是糟糕的UI设计。
#2
Although i understand and even share your frustration, there are some legit reasons to do that.
虽然我理解甚至分享你的沮丧,但有一些合理的理由这样做。
Many companies have sites tailored to each specific country. For example, because they don't sell all their products to every country, or because a law in a specific country put some specific obligation on their site (a line of product banned, a legal notice added, or whater, ...).
许多公司都有适合每个特定国家的网站。例如,因为他们不会将所有产品销售给每个国家,或者因为特定国家/地区的法律在其网站上放置了一些特定义务(禁止使用产品线,添加法律声明,或者更新,......) 。
Therefore, they will serve you the version tailored to the country you're in because that's supposed to be the most useful (it doesn't matter that company X is selling product Y in country Z if i'm not currently in country Z).
因此,他们将为您提供适合您所在国家/地区的版本,因为这应该是最有用的(如果我目前不在Z国家,公司X在Z国销售产品Y并不重要) 。
#3
Google is smart. I imagine they do what they do because for the majority of cases if you're in Vietnam you most likely want .vn
- we're technical people so we know all about accept-language and such, but the vast majority of people don't.
谷歌很聪明。我想他们会做他们做的事情,因为在大多数情况下,如果你在越南,你很可能想要.vn - 我们是技术人员,所以我们都知道所有接受语言等等,但绝大多数人都不喜欢吨。
That being said, I think one thing they could to at least be polite to the accept-language header, is to show some kind of notification (kind of like the banners that show in this website) saying something like "Looking for Google in English? Click here" if the header indicated they want english - while that may not work for Google (as they don't do it), I would certainly consider that if I was making a multilingual website.
话虽如此,我认为他们可以至少对接受语言标题有礼貌,就是要显示某种通知(有点像本网站上显示的横幅),说“用英语寻找谷歌” ?点击这里“如果标题表明他们想要英语 - 虽然这可能不适用于谷歌(因为他们不这样做),我当然会考虑如果我正在制作一个多语种网站。
#4
I'm betting that there are more people use software that doesn't properly utilize this HTTP header value than there are people who live in a country and don't speak/read the native tongue. That would explain Google's behavior.
我敢打赌,有更多人使用的软件没有正确使用这个HTTP标头值,而不是生活在一个国家并且不会说/读本土语言的人。这可以解释谷歌的行为。
#5
I share your frustration. I've been disappointed by a great number of sites. Most do IP-geolocation but obviously have no idea about the browser culture settings. Needless to say, the user location is an unreliable information source about which language and culture the user prefers. Especially in the times of globalization where peoples and cultures are highly mixed.
我分享你的沮丧。我对很多网站感到很失望。大多数人做IP地理定位,但显然不了解浏览器文化设置。不用说,用户位置是关于用户喜欢哪种语言和文化的不可靠信息源。特别是在人口和文化高度混合的全球化时代。
Note that I read the HTTP 1.1 specification from 1999 but they seem to omit the question of how much the Accept-Language should be really taken into consideration.
请注意,我从1999年开始阅读HTTP 1.1规范,但它们似乎省略了应该如何真正考虑Accept-Language的问题。
This setting is actively supported by modern browsers. There is no good reason not to take it into consideration. If the header is not present in the request, do geolocation, otherwise respect the user culture setting.
现代浏览器积极支持此设置。没有理由不考虑它。如果请求中不存在标头,请执行地理位置,否则请遵守用户区域设置。
#6
I'f from Latvia, I prefer English. Firefox sends en-US by default, IE sends lv-LV (even though it is English version) because of Windows regional settings. So accept-header is unreliable.
我来自拉脱维亚,我更喜欢英语。 Firefox默认发送en-US,因为Windows区域设置,IE发送lv-LV(即使它是英文版)。所以accept-header是不可靠的。
IMHO best way is to do both geolocation and accept-language check,
恕我直言最好的方法是做地理定位和接受语言检查,
if region and language matches => auto redirect if there is no match => serve your best guess and give user a choice (maybe top right corner of the screen is the best place for language switch as it is UI standard more or less) + remember that choice in a cookie
如果区域和语言匹配=> auto redirect如果没有匹配=>提供你最好的猜测并给用户一个选择(可能是屏幕的右上角是语言切换的最佳位置,因为它或多或少是UI标准)+记住在cookie中的选择
#7
I'm guessing that a significant percentage of people in non-English speaking countries use browsers that report Accept-language of English (perhaps because they use pirated English versions, who knows).
我猜测非英语国家的很大一部分人使用报告英语接受语言的浏览器(也许是因为他们使用的是盗版英语版本,谁知道)。
Most of them, aside from a vocal minority on a English-language programming web site :), would expect to see web sites in their own language, and the common folk don't care about HTTP specifications. This would make the Accept-language header essentially useless, a perfect example of how the real world != programmer fantasy world.
除了英语编程网站上的少数人之外,他们中的大多数人都希望看到自己语言的网站,普通人不关心HTTP规范。这会使Accept-language标题基本无用,这是现实世界!=程序员幻想世界的完美例子。
#8
I agree Google is misbehaving. I suspect this is a result of a structural over-optimization. If you put servers close to users, and your goal is insanely fast results, you're better off serving a single cache of search results in a single language, off of each local server cluster.
我同意谷歌行为不端。我怀疑这是结构过度优化的结果。如果您将服务器放在用户附近,并且您的目标是非常快速的结果,那么最好使用单一语言(每个本地服务器群集)提供单个搜索结果缓存。
That means when your IP comes in, it's not so much IP Geolocation as, which server cluster answered your request first. And that cluster nearest to you in Vietnam is optimized to serve pages in Vietnamese.
这意味着当您的IP进入时,IP地理位置并不是那么多,哪个服务器群集首先回答了您的请求。而在越南最接近你的群集被优化为用越南语提供页面。
I'm sure this is resolvable but I wouldn't be surprised if the design of that optimization makes it difficult for them to fix.
我确信这是可以解决的,但如果优化的设计使他们难以修复,我不会感到惊讶。