.NET 3.5 中的 CultureInfo 类支持哪些文化?
我需要 .NET 3.5 支持的文化列表,无论使用什么操作系统。 这似乎很难获得,但我不知道为什么!
编辑:啊,我不知道它依赖于操作系统,这可以解释缺乏文档的原因。关于 Mac/Linux 操作系统也支持什么有什么想法吗?
谢谢 :)
I need a list of cultures that are supported by .NET 3.5, regardless of the OS used.
This seems to be quite a struggle to obtain, though I am not sure why!
Edit: Arghh, I was not aware that it is dependent on the OS, that would explain the lack of documentation. Any ideas on what is supported by Mac/Linux OS as well?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不幸的是,它依赖于操作系统。请在此处查看每个操作系统的默认语言支持。
请注意,CultureInfo 文档警告:
在 ASP.NET 中,浏览器比操作系统更重要。它可以通过 Accept-Language 告诉您用户喜欢哪种语言(第 14.4 节)请求标头。如果您将应用的全球化配置设置为enableClientBasedCulture="true",则 ASP .NET 将尝试自动将 UICulture 和 Culture 设置为浏览器提供的值。或者,您可以通过检查 Request.UserLanguages 手动设置文化 属性:
不幸的是,无法从操作系统或浏览器生成可能语言的详尽列表。最接近的是 IANA 语言子标签注册表。这是 RFC 4646 中描述的语言注册表 - 定义 .NET 的 CultureInfo 标记的文档。
请记住,Request.UserLanguages 中的语言标签不保证有效。你会想要检查它们。 HTTP 1.1 使用旧的建议语言标签,并且有没有什么可以阻止某人在语言标头中发送乱码。
Unfortunately, it is OS dependent. Check here for default language support per OS.
Note, the CultureInfo documentation warns:
In ASP.NET, it's the browser that's important versus the OS. It can tell you which language the user prefers via the Accept-Language (Section 14.4) request header. If you set your app's globalization configuration to enableClientBasedCulture="true", ASP.NET will try to automatically set the UICulture and Culture to the value provided by the browser. Alternatively, you can set Culture manually by inspecting the Request.UserLanguages property:
Unfortunately, there's no way to generate an exhaustive list of possible languages from an OS or browser. The closest thing is the IANA Language Subtag Registry. This is the language registry described in RFC 4646 - the document that defines .NET's CultureInfo tags.
Keep in mind, language tags in Request.UserLanguages are not guaranteed to be valid. You'll want to check them. HTTP 1.1 uses an older recommendation for language tags and there's nothing stopping someone from sending gibberish in the language header.
国家语言支持 (NLS) API 参考列出了区域设置信息并允许您选择操作系统。
Microsoft Locale Builder 是一个为 Windows Vista 及更高版本创建自定义区域设置的工具。
获取操作系统支持的区域性列表,包括自定义区域性。
C# 示例,
National Language Support (NLS) API Reference lists locale information and allows you to select the OS.
Microsoft Locale Builder is a tool to create custom locales for Windows Vista and later.
Get a list of supported cultures, including custom ones, for the OS.
C# Example,
可以创建自定义区域性,但默认类支持您所运行的操作系统提供的那些区域性。 MSDN 上有默认支持的文化参考
It is possible to create custom cultures, but the default class supports those cultures provided by the operating system you're running on. There is a reference of the cultures supported by default on MSDN
我刚刚检查了 Culture Explorer 2.0,纯 Windows 文化和已安装的文化以及 .NET Framework 文化(至少在我的系统上,仅包含纯语言文化)之间存在区别。所有这些都由 CultureInfo 类(以及 RegionInfo、NumberFormatInfo 等)支持。
我还在 Mono(在 Linux 上)上运行了它,大致相同,缺少 .NET Framework 文化和仅限 Windows 的文化,但存在特定和中性文化。不过,RegionInfo.CurrencyNativeName 似乎没有在我的 Mono 版本中实现,因此在选择任何区域性时会崩溃。
不幸的是,Culture Explorer 2.0 目前无法从任何地方获得(在gotdotnet.com 上),我前段时间下载了它。对于此类事情来说,这是一个方便的工具。您可能会幸运地在某些档案中找到一个。
I just checked with Culture Explorer 2.0, there is a distinction between Windows-only cultures and installed cultures, as well as .NET Framework cultures (which, at least on my system, only contain language-only cultures). All of these are supported by the CultureInfo class (and RegionInfo, NumberFormatInfo and so on).
I also ran it on Mono (on Linux), it's roughly the same, with the .NET Framework cultures and the Windows-Only cultures missing, but the Specific and Neutral cultures are there.
RegionInfo.CurrencyNativeName
seems not to be implemented in my Mono version though, so it crashes when selecting any culture.Unfortunately, Culture Explorer 2.0 is currently not available from anywhere (was on gotdotnet.com), I downloaded it some time ago. It's a handy tool for such things. You may have luck to find one in some archives.