gpt4 book ai didi

asp.net - CultureInfo.CurrentCulture 从哪里读取文化

转载 作者:行者123 更新时间:2023-12-04 10:10:25 25 4
gpt4 key购买 nike

我想知道设置或位置从哪里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.



换句话说,它基于线程,女巫有一个上下文...在 ASP.NET 上下文中,来自 语言环境 用于 客户端浏览器优先 如果使用 Server Variables或其他所有内容的系统设置。

在此 Web 上下文中,您可以使用 Server.Variables 获取它。方法在 HTTP_ACCEPT_LANGUAGE你会得到类似的东西:
en-US,en;q=0.8,pt-PT;q=0.6,pt;q=0.4

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

一切来自 System.Globalization来自 系统定义 就像下图所示:

enter image description here

上面的代码是:

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

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

enter image description here

关于asp.net - CultureInfo.CurrentCulture 从哪里读取文化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9697604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com