开发者

How to prioritize internationalization parameters

given that these all have different values:

  • HTTP browser accept language header parameter

  • 开发者_JAVA技巧

    HTTP GET human language parameter eg. hl=en or hl=fr

  • Cookie value for language choice

How should we decide which language to display pages in if deciding based on these values? It's also thinkable saving user's preferred language to the data layer for a fourth way to let agents and users decide language. Thanks in advance for answers and comments


If you have a saved preference somewhere, then that would be the first choice.

The cookie value is, presumably, what they chose last time they were around so that would be the first thing to check.

The hl parameter is something that Google has figured out and they probably know what they're doing so that seems like a sensible third choice.

Then we have the HTTP headers or a final default so check the accept language header next. And finally, have a default language in place just in case all else fails.

So, in order:

  1. Saved preference.
  2. Cookie.
  3. hl parameter.
  4. HTTP accept language header.
  5. Built in default.

Ideally you'd backtrack up the list once you get a language from somewhere so that you'd have less work to do on the next request. For example, if you ended up getting the language from the accept language header, you'd want to: set hl (possibly redirecting), store it in the cookie, and save the preference in their user settings (if you have such a permanent store and a signed in person).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜