13

我需要一个 .NET 3.5 支持的文化列表,无论使用什么操作系统。这似乎很难获得,虽然我不知道为什么!

编辑:啊,我不知道它依赖于操作系统,这可以解释缺乏文档。关于 Mac/Linux 操作系统也支持什么的任何想法?

谢谢 :)

4

4 回答 4

8

Unfortunately, it is OS dependent. Check here for default language support per OS.

Note, the CultureInfo documentation warns:

Windows versions or service packs can change the available cultures.

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.

于 2010-02-17T16:37:47.437 回答
4

国家语言支持 (NLS) API 参考列出了区域设置信息并允许您选择操作系统。

Microsoft Locale Builder 是一个为 Windows Vista 及更高版本创建自定义语言环境的工具。

获取操作系统支持的文化列表,包括自定义文化。

C# 示例,

System.Globalization.CultureInfo[] cultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures);
于 2010-04-14T12:59:08.157 回答
1

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

于 2010-02-17T16:39:55.840 回答
0

我刚刚检查了 Culture Explorer 2.0,仅 Windows 的文化和已安装的文化以及 .NET Framework 文化(至少在我的系统上仅包含仅语言文化)之间存在区别。所有这些都由 CultureInfo 类(以及 RegionInfo、NumberFormatInfo 等)支持。

我也在 Mono(在 Linux 上)上运行它,它大致相同,缺少 .NET Framework 文化和仅限 Windows 的文化,但存在特定和中性文化。RegionInfo.CurrencyNativeName不过似乎没有在我的 Mono 版本中实现,因此在选择任何文化时它都会崩溃。

不幸的是,Culture Explorer 2.0 目前无法从任何地方获得(在 gotdotnet.com 上),我前段时间下载了它。这是处理此类事情的便捷工具。您可能很幸运能在某些档案中找到一份。

于 2010-02-17T16:58:48.907 回答