什么是检测语言的最佳方法? [英] What's best method to detect language?

查看:64
本文介绍了什么是检测语言的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im建立一个网站(wordpress多站点),该网站受2种语言支持,用户可以使用以下两种方法:

im making a website (wordpress multisite) which is supported by 2 languages for users, there 2 methods we will use it one:

-通过Geo IP检测语言

-Detect language by Geo IP

-通过Internet浏览器检测语言

-Detect Language by Internet Browser

哪种方法是最好的使用方法?

Which is the best method to use it?

预先感谢!

推荐答案

如果我是我,请按照以下列表操作:

  1. 如果用户是注册用户,请根据他/她的喜好设置语言

  1. If the user is a registered user, set the language according to his/her preferences

如果用户以前曾在该网站上使用过语言X,请使用该语言(将语言选项存储在cookie中).

If the user has been on the site before, using language X, use that (store the language option in a cookie).

如果存在http标头 Accept-Language ,请尝试使用它(您显然不支持世界上所有的语言).在PHP中,您可以通过 $ _ SERVER ['ACCEPT_LANGUAGE'] 保留此值.

If the http header Accept-Language is present, try to make use of it (you obviously don't support all the languages in the world). In PHP you can get a hold of this value through $_SERVER['ACCEPT_LANGUAGE'].

我已经看到人们也使用 Accept-Charset ,如果不能使用指定的语言(在Accept-Language中),则试图缩小它的范围.虽然开枪了.

I have seen people make use of Accept-Charset as well, trying to narrow it down if the languages specified (in Accept-Language) can't be used, that is kind of a long shot though.

最终选项是使用Geo IP来尝试找出用户可能在世界上的哪个地方以及在那里说什么语言.尽管这是一项艰巨的任务,因为一国的官方语言可能不是最终用户首选的语言.

Final option is to use Geo IP to try and figure out where in the world the user might be, and what language is spoken there. This is a tough one though since the official language in a country might not be the one preferably used by the end user.


只要用户可以轻松更改语言并且不受上述任何预设的约束,就不会有任何问题.


As long as the user can easily change language and isn't bound to any of the above presets there shouldn't be any problem.

..并且请;尝试跟踪用户以前使用过的语言,以便他/她每次访问您的网站时都不必更改语言.

.. and please; try to keep track of what language a user has been using before so that he or she doesn't have to change language every time he/she visits your site.

这篇关于什么是检测语言的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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