网站(Google和/或您)应如何处理Accept-Language标头? [英] How should sites (Google and/or you) treat Accept-Language header?

查看:174
本文介绍了网站(Google和/或您)应如何处理Accept-Language标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间以来,我对以下情况下Google的行为感到不满意,并且在意外地注意到 80多个其他人也有同感(20多人赞成谷歌错误报告的想法)我认为在HTTP上利用SO的智慧是有用的协议和网络文化。

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.

每次我去其他国家并访问 google.com 时会出现此行为从我的笔记本电脑或安装新的浏览器。在包括越南在内的许多国家/地区,Google会自动重定向到本地化版本(例如 google.com.vn ),一个我实际上无法阅读,所以我扫描它,拼命寻找 Google.com in English 链接。

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.

第一次发生时,我很困惑,花了一些时间找出我的请求标题可能出错的地方;正如我所料,我的 Accept-Language 总是 en-US 或类似 en- US,如; q = 0.5 。使用不同IP的进一步测试证实,即使您已登录,它们也会进行IP地理定位。后来我了解到语言查询?hl = ... ,但仍然如此。

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.

所以,我的问题是:你认为这是合理的,预期的行为吗?其他网站也这样做吗? 如果你要设计一个多语言网站,你会对来自 .vn IP但是 en-US 语言?

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?

我想有不同的IP地理定位方法:

I imagine there are different approaches to IP geolocation:


  • 反对:我认为这是不礼貌的:我明确告诉你我想要什么,
    给我一些其他什么好处?

  • 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.

contra :然而,非技术人员可以通过安装语言包轻松更改接受语言。事实上,如果你去下载Firefox,很可能你会用你想要的语言下载一个,使用符合你意愿的接受语言标题。

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.

请注意,我读过 HTTP 1.1规范,但它们似乎省略了 Accept-Language

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.

我认为这个问题属于SO作为网络应用程序设计问题。而且我还在考虑提交正式的错误报告(如果我说的话,这种行为远非网络标准)。

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).

推荐答案

<我认为这里有两个独立的问题。语言和国家。他们绝对不是一回事。 HTTP规范明确将Accept-Language请求标头字段定义为语言说明符,而不是国家/地区说明符。

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.

例如:en-US是指特定语言(主要在美国使用的英语版本),en-GB是指另一种语言(主要在英国使用的英语版本)。这与您目前在世界上的位置无关,它只定义了您在查看网站时最容易接受的语言。并且应该得到尊重,因为即使新手用户也应该使用他们语言的浏览器,默认情况下会发送正确的请求标头字段。

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.

但这不是传统上使用它的网站。像另一张海报一样,我注意到网站将语言与国家等同,并将其网站定制为该国家独特的政治限制/自由/公司在那里的产品,而不一定是语言。给出的例子是一家公司不在特定国家销售特定产品,但在其他国家销售特定产品。

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.

如果要为不同国家/地区展示哪些产品,地理定位IP地址比根据语言做出决策要好,但它仍然不完美。如果我暂时在另一个国家,但想订购一些东西并将其送回家,该怎么办?如果我的IP地址没有反映我的身体状况,这不完美怎么办?

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?

是的,大多数时候,大多数人都能正常工作。但是为什么在地球上你会让人们难以用他们要求的语言获取网站?这只是糟糕的UI设计。

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.

这篇关于网站(Google和/或您)应如何处理Accept-Language标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆