加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – CultureInfo.CurrentCulture从中读取文化

发布时间:2020-12-16 00:10:54 所属栏目:asp.Net 来源:网络整理
导读:我想知道System.Globalization.CultureInfo.CurrentCulture读取其值的设置或位置. 我使用的是Windows 7笔记本电脑,并将我的系统区域和日期时间设置更改为美国. 我在下面的web.config设置下使用了我的代码 globalization culture="en-US" / 谢谢 解决方法 MSD
我想知道System.Globalization.CultureInfo.CurrentCulture读取其值的设置或位置.

我使用的是Windows 7笔记本电脑,并将我的系统区域和日期时间设置更改为美国.

我在下面的web.config设置下使用了我的代码

<globalization culture="en-US" />

谢谢

解决方法

MSDN说

The culture is a property of the executing thread. This read-only property is equivalent to retrieving the CultureInfo object returned by the Thread.CurrentCulture property. When a thread is started,its culture is initially determined by calling the Windows GetUserDefaultLocaleName function.

换句话说,它基于Thread,在ASP.NET上下文中有一个上下文…来自客户端浏览器中使用的Locale,如果使用服务器变量或其他所有的系统设置.

在这个Web上下文中,您可以使用HTTP_ACCEPT_LANGUAGE上的Server.Variables方法获取它,您将得到类似的内容:

en-US,en;q=0.8,pt-PT;q=0.6,pt;q=0.4

Witch声称客户端浏览器设置了3种语言,其中第一种是en-US.

System.Globalization的所有内容都来自系统定义,如下图所示:

上面的代码是:

<p>
    <pre>System.Globalization.CultureInfo.CurrentCulture</pre> 
    is @System.Globalization.CultureInfo.CurrentCulture.EnglishName
</p>

无论使用什么浏览器,System.Globalization的定义将始终来自操作系统定义

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读