是否有可能来确定用户的语言环境的国家** **在从JavaScript的浏览器设置操作系统? [英] Is it possible to determine the user locale's **country** as set in the OS from the browser in JavaScript?

查看:117
本文介绍了是否有可能来确定用户的语言环境的国家** **在从JavaScript的浏览器设置操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

做网页浏览器都可以访问任何的语言环境设置的界面,用户在操作系统中设置?

Do web browsers have an interface to access any of the locale settings as set in the operating system by the user?

我可以检测用户的目前在哪个国家从他们的IP地址,或使用新的地理位置API,但我正在为旅客浏览器的应用程序,所以我希望他们的当前位置到常不是他们的本国

I can detect what country the user is currently in from their IP address or using a the new geolocation API, but I'm writing a browser app for travellers so I expect their current location to often not be their home country.

有什么方法来确定什么的国家/区域设置的浏览器/操作系统设置为?

Is there any way to determine what country/locale the browser/OS is set to?

如果不是有没有适当的语言环境支持添加到JavaScript的任何建议?

If not is there any proposal to add proper locale support to JavaScript?

另外还有什么聪明的解决方法? (比如我​​知道我能得到用户的preferred浏览的语言但也有很多的国家使用相同的语言并大量是谁请设定为默认值,而不是将其改为自己常用语言的用户。)

Also are there any clever workarounds? (For instance I know I can get the user's preferred browsing language but there are plenty of countries which use the same language and plenty of users who keep this set to the default rather than changing it to their usual language.)

推荐答案

你会得到最好的是语言:

The best you'll get is languages:


  • navigator.language(网景 - 浏览器本地化)

  • navigator.browserLanguage(IE特定的 - 浏览器本地化语言)

  • navigator.systemLanguage(IE-具体 - Windows操作系统 - 本地化语言)

  • navigator.userLanguage

由于无论是安全问题,或只是没有实现,你所要求的是不可能的,本身。但是,您可以使用ActiveX对象,您的Windows用户

Due to either security concerns or just not implemented, what you have requested is not possible, natively. You can however use an ActiveX object for your Windows users

您可以有一个用户选择他们perfered语言,国家等则使用JavaScript来设置cookie,这将被发送到你的服务器随时请求一个页面

You could have a user select their perfered language, country, etc then use javascript to set a cookie, which will be sent to your server anytime a page is requested

这篇关于是否有可能来确定用户的语言环境的国家** **在从JavaScript的浏览器设置操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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