javascript 获取网站访问者的区域设置(语言)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11889925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:40:42  来源:igfitidea点击:

Get locale (language) of website visitor?

javascripthtml

提问by Javier Manzano

I'm developing a webite and I'm trying to guess how to get the clients current locale.... This web does use JQuery and Javascript a lot, so is there any way using it?

我正在开发一个网站,我正在尝试猜测如何让客户端获得当前的语言环境......这个网站确实使用了 JQuery 和 Javascript,那么有什么方法可以使用它吗?

Thanks!

谢谢!

采纳答案by Edward Ruchevits

Try thisjQueryplugin for obtain the browser language setting.

试试这个jQuery插件来获取浏览器语言设置。

Example usage:

用法示例:

$.browserLanguage(function( language , acceptHeader ){
    alert("You have your browser language set to " + language);
})