网站应该如何处理本地化设置? (来自“常见的 UI 误解和烦恼是什么?”)
我选择将其作为一个问题本身,因为它在 原始帖子。
有趣的是,很多 SO 上的人(他们是开发人员)都没有获得本地化。 以下是我对它应该如何工作的看法:
在我见过的所有浏览器(以及 .NET 开发人员)中,当您查看用户的文化偏好时,它采用以下格式: 语言文化。
所以我们有:
- en-GB - 英语 - 英国文化
- en-US - 英语 - 美国文化
- en - 英语 - 不变文化。
- fr-FR – 法语 – 法国文化
- fr-CH – 法语 – 瑞士文化
- de-CH – 德语 – 瑞士文化
- de-DE – 德语 – 德国文化
请参阅 MSDN 了解 .NET 框架支持的完整列表。
当我访问一个网站时,它知道我想要 en 部分的英语,并且它知道我对它倾向于英国感兴趣(数字格式、日期格式)。 因此,当我访问 google.com 时,它会将我带到 google.de(因为我的 IP 地址),如果 google.de 以英语向我显示所有内容,那完全没问题,但由于 google.de 是德语,所以完全错误。 我几乎无法控制自己的 IP 地址,但可以完全控制自己的语言和文化设置。 如果您感兴趣,微软的新搜索引擎(bing.com)可以正确处理事情。 我们希望 Microsoft 能够像 Google 一样学习如何进行搜索,或者 Google 能够像 Microsoft 一样学习如何本地化 ;)
MSDN 这里有另一篇很好的文章来了解更多信息
那么,您对网站应如何处理本地化有什么建议?
I’ve chosen to take this as a question in its own right since it was generating so much debate in the comments of the original post.
It’s interesting to see that a lot of people on SO (who are developer's) just don't get localization. Here’s my take on how it should work:
In all browsers that I've looked at (and for the .NET developers out there too) when you look at a user's culture preferences it is in the following format:
language-Culture.
So we have:
- en-GB - English language - UK culture
- en-US - English language - US culture
- en - English language - Invariant culture.
- fr-FR – French language – French culture
- fr-CH – French language – Swiss culture
- de-CH – German language – Swiss culture
- de-DE – German language – German culture
See MSDN for a complete list that the .NET framework supports.
When I go to a website it knows that I want the English language from the en part and it knows I’m interested in it being slanted to the UK (number formatting, date formatting). So when I go to google.com and it takes me to google.de (because of my IP address) that’s completely fine if google.de displays everything to me in English but completely wrong since google.de is in German. I have little control over my IP address but complete control over my language and culture settings. If you’re interested Microsoft’s new search engine (bing.com) handles things properly. Let's hope Microsoft can learn how to do search as well as Google or Google can learn to localize as well as Microsoft ;)
MSDN has another good article here for more information
So what are your recommendations for how sites should deal with localizations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这里的解决方案非常简单,开发人员做其他事情很烦人。
尊重浏览器设置。 如果它说英语,那么天哪,它就是英语。
如果您绝对必须这样做,那么只需在顶部添加一个按钮即可选择其他内容。 然后,也只有到那时,您才会覆盖浏览器。
如果你认为你的方式更好。 停下来,让人打你一巴掌。 它不是。 根据需要重复。
摆脱那些询问某人所在国家/地区的网页。 只需根据浏览器默认设置显示您的正常页面,然后参见上面的第 2 项。
我还没有遇到过一个真正重要的网站。更新: 几年后,现在有理由这样做。 2013 年,英国制定了有关 Cookie 的政策,网站运营商需要尊重位于该国、向该国访问者提供页面的网站。 因此,请注意您所在国家/地区的法律。如果您碰巧有一个站点确实由多个国家/地区的多个服务器提供服务,那么您可能可以检测到您的哪一台服务器离服务真的很近。 如果你做不到,就停止疯狂的重定向,然后不要尝试为它们做出决定。
The solution here is so simple, it's annoying that dev's do anything else.
Respect the browser setting. If it says English then by god it's English.
If you absolutely must, then simply add a button at the top to pick something else. Then, and ONLY then, do you override the browser.
If you think your way is better. Stop, have someone slap you. It's not. Repeat as necessary.
Get rid of those web splash pages that ask for someone's country. Just show your normal page, based off of the browser defaults, and see item 2 above.
I have yet to run into a site where it actually matters.update: a few years later and there is now a reason to do this. In 2013 the UK instituted policies surrounding cookies that website operators need to respect for sites based in that country that are serving pages to visitors from that country. So pay attention to the laws in the countries you are hosted in.IF you happen to have a site that really is served by multiple servers across multiple countries, then you can probably detect which one of your servers is really closer to serve from. If you can't, just stop the redirecting madness and then don't try and make a determination for them.
如果本地化设置可用 - 包括但不限于 HTTP Accept-Language 标头 - 那么网站绝对应该尊重它们。
反对这一点的常见论点是“普通用户”不够聪明,无法找到语言设置并将其配置为符合自己的偏好,因此这些设置通常是不正确的(除非用户碰巧在我们)。
那是错误的解决方案。
如果很大一部分用户无法找到(或懒得找到)他们的浏览器语言设置,那么正确的反应是让它们更容易找到,而不是让网站忽略他们的设置。 也许可以从程序的顶级菜单直接访问语言设置,而不是将其隐藏在过于复杂的“首选项”对话框中。 也许在程序第一次运行时询问语言首选项。 也许使用操作系统的本地化设置。 或者也许是完全不同的东西,如果这就是使浏览器几乎确定将发送有关用户偏好的正确信息所需要的。 但不要只是举手,说“它没用,无法修复!”,然后忽略它。
其他答案谈到让用户在网站上的个人资料中选择语言或区域设置,这也很重要并且绝对应该是标准的,但这只是为了提供特定于网站的覆盖用户的正常设置。 但是,如果用户没有在网站上覆盖此设置,则正确的操作是默认使用其浏览器设置中指定的最首选的可用语言/区域设置,而不是基于其 IP 地址的地理位置。
If localization settings are available - including, but not limited to, the HTTP Accept-Language header - then websites absolutely should respect them.
The common argument against this is that "average users" aren't smart enough to find the language settings and configure them to match their own preferences, so these settings are, more often than not, incorrect (unless the user happens to be within the US).
That is the wrong solution.
If a substantial segment of the user population can't find (or can't be bothered to find) their browser's language settings, then the correct response is to make them easier to find, not for sites to ignore what they've been set to. Perhaps make language settings directly accessible from the program's top level menu instead of burying it inside an over-complicated "Preferences" dialog. Perhaps ask for language preferences the first time the program is run. Perhaps use the operating system's localization settings. Or maybe something completely different, if that's what it takes to make it near-certain that the browser will be sending correct information about the user's preferences. But don't just throw up your hands, say "it's useless and can't be fixed!", and ignore it.
Other answers have talked about letting the user choose a language or locale in their profile on the site, which is also important and absolutely should be standard, but that's just to provide a site-specific override to the user's normal settings. If the user has not overriden this on the site, though, the correct action is to default to the most-preferred available language/locale as specified in their browser settings, not to base it on geolocation of their IP address.
在我的职业生涯中,我曾维护过部分 TCP/IP 堆栈。 这让我非常清楚地知道 IP 地址不应该用作网络层地址以外的任何内容。 IP 地址和位置之间的任何关联几乎都是巧合 - 这是地址分配方式的产物,而不是 IP 地址含义的任何基本部分。
(它们也不能作为计算机的唯一标识符,但这是一个不同的故事)
我建议将地理定位排除在外。 HTTP 标准包括一种让浏览器或其他用户代理在每个请求中包含用户文化偏好的方法(请记住,它是加权偏好列表,不一定只是一种文化)。 由于浏览器比您更接近用户,因此您应该尊重此请求,至少作为默认请求。
然后允许用户暂时或永久更改他们对您网站的偏好就可以了。 甚至可以允许用户选择查看具有不同文化设置的不同内容。 一个疯狂的例子是一个同时包含政治新闻和技术信息的网站。 有人希望以他们的“自然”语言获得新闻,但以英语获得技术信息,这是很合理的。
最后,有一个后备模式是可以的。 例如,如果您有一个根据用户所在区域(例如经销商)为用户提供服务的网站,那么日语内容可能只存在于您的亚洲区域子网站上。 访问您的 EMEA 网站的日语用户可能只会看到英文内容,这很可能是他的最后选择。
At one point in my career, I maintained parts of TCP/IP stack. That puts me in the somewhat rare position of knowing very well that IP addresses should not be used as anything other than Network-layer addresses. Any association between an IP address and a location is all but coincidental - it's an artifact of the way addresses are distributed, not any fundamental part of what an IP address means.
(They're also not useful as the unique identifier of a computer, but that's a different story)
I suggest leaving geolocation out of it. The HTTP standard includes a way for a browser or other user agent to include the users culture preferences with each request (and remember, it's a list of weighted preferences, not necessarily just one culture). Since the browser is closer to the user than you are, you should honor this request, at least as the default.
It's ok to then permit the user to change their preference for your site, either temporarily or permanently. It's even ok to allow the user to choose to view different content with different culture settings. A wild example would be a site that includes both political news and technical information. It's quite reasonable that someone would want the news in their "natural" language, but the technical information in English.
Finally, it's ok to have a fallback pattern. If, for instance, you have a site that services users based on their region (resellers, for instance), then it's possible that Japanese content only exists on your Asian regional sub-site. A Japanese-speaking user visiting your EMEA site might just be stuck seeing English content, which might very well be his last choice.
在我创建的网站上,我通常遵循以下模式:
/en/page
或不同的(子)域/page
这样的未指定语言我开始猜测:Accept-Language
是否可用?我可以将其映射到网站上可用的语言吗?/en/page
可以轻松切换到/xx /页面
理想情况下,我只需要猜测一次,然后就使用用户的 cookie,或者用户直接访问所需的页面。
On the sites I create I usually follow this pattern:
/en/page
or a different (sub)domain/page
I start to guess:Accept-Language
available and can I map it to a language available on the site?/en/page
can easily be switched to/xx/page
Ideally I only have to guess once and from then on use the user's cookie, or the user visits the desired page directly.
我同意,让用户有机会在您的应用程序中使用用户首选项覆盖它们。 这对于无法从浏览器设置中得出的时区本地化问题特别方便。
I agree, give the user the chance to override them with user preferences in your app. This is especially handy for things like timezone localization issues which you can't derive from browser settings.
我冒着被认为不礼貌的风险,但我认为我的 关于这个主题的帖子将会有更多信息性的答案,主要是因为我的帖子确实是一个问题。 很抱歉我之前没有找到那个帖子。
I risk being considered impolite, but I think my post on this topic will have more informative answers, mostly because my post is really a question. I am sorry though that I did not find that post before.
智能默认值和用户覆盖默认值的能力之间存在差异。 在我开发的大型应用程序中,我通过浏览器设置、地理位置等假设了用户的区域设置,但始终为用户提供了一种轻松切换的方法。
我不知道还有什么办法可以做到这一点。 不给用户机会纠正你的假设是很成问题的,因为有时你会出错。
另外:
我认为你的问题是,虽然你可以编辑你的区域设置,但如果它们看起来与默认设置基本相同,应用程序开发人员就无法判断你是故意保留它,还是因为你不这样做知道如何或为何改变它。
我建议尊重用户的本地化设置,除非该设置是压倒性的默认设置,用户不得更改。 例如,我相信绝大多数 (90+%) 的
en-us
设置位于越南的用户几乎总是会通过查看越南语内容而不是美国英语内容获得更好的服务,只要因为有一种简单的方法可以切换区域设置。 另一方面,如果位于美国的用户有越南语设置,请务必向他或她提供越南语内容。这会让越南的美式英语用户感到恼火吗? 当然。 但这也是为最大多数人带来最大好处,并有助于确保普通非技术用户获得最佳的现实体验。 在我们能够用枪指着用户的头并迫使他们在打开计算机之前诚实地声明他们的语言/文化偏好之前,我们将需要这样的启发式方法。
There's a difference between smart defaults and the ability of users to override them. In big apps I've worked on, I've assumed the user's locale from browser settings, geolocation, etc. -- but always given users a way to easily switch.
I don't know how else one would do that. Not giving users a chance to correct your assumptions is deeply problematic, because you're going to get it wrong some of the time.
ADDITION:
I think your problem here is that while you can edit your locale settings, if they look basically identical to the default, there's no way for an application developer to tell if you left it as-is intentionally, or because you don't know how or why to change it.
I suggest honoring users' localization settings, except if the setting is the overwhelming default, which users may not change. For example, I believe the great majority (90+%) of users with an
en-us
setting geolocated in Vietnam would almost always be better served by seeing Vietnamese content, rather than US English content, as long as there's a trivial way to switch locales. On the flip side, if a user geolocated in the US has a Vietnamese setting, by all means give him or her Vietnamese content.Is this irritating for US-English users in Vietnam? Sure. But it's also the greatest good for the greatest number, and helps ensure that average non-technical users get the best real-world experience. Until we can hold a gun to users' heads and force them to honestly declare their language/culture preferences before turning on a computer, we're going to need heuristics like this.
我已经看到来自客户的足够有力的错误报告,经过调查发现其中一位用户的浏览器文化设置错误,我们现在让客户使用配置设置覆盖浏览器。 浏览器的文化设置经常是错误的,这不是很有用,而且对于大多数最终用户来说也很难找到或更改它。
I have seen enough forceful bug reports from customers that when investigated turn out to be that one of there users had the browser's culture setting wrong, that we now let the customer override the browsers with a config setting. The browser's culture setting is wrong often enough that is it not very useful, it is also too hard for most end users to find or change it.