.net - 中文代码

标签 .net localization .net-2.0 cjk

我们正在将旧的 .net 1.1 网站更新到 2.0。本站目前支持
中文(繁体)和中文(简体)

尝试使用以下代码检测语言和文化时出现运行时错误:
zh-CHS(简化版)和 zh-CHT(传统版):

请选择特定的文化,例如 zh-CN、zh-HK、zh-TW、zh-MO、zh-SG。

来自:System.Globalization.CultureInfo.CreateSpecificCulture(字符串名称)

看来这些是过时的语言/文化代码。有没有人对我如何将这些语言映射到支持的特定国家/地区/文化有任何见解?

最佳答案

我会在这里看看:

http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.parent(VS.80).aspx

具体来说,

/*
This code produces the following output.

SPECIFIC CULTURE                                  PARENT CULTURE
0x0404 zh-TW Chinese (Taiwan)                     0x7C04 zh-CHT Chinese (Traditional)
0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified)
0x0C04 zh-HK Chinese (Hong Kong S.A.R.)           0x7C04 zh-CHT Chinese (Traditional)
0x1004 zh-SG Chinese (Singapore)                  0x0004 zh-CHS Chinese (Simplified)
0x1404 zh-MO Chinese (Macau S.A.R.)               0x7C04 zh-CHT Chinese (Traditional)

*/

和:

The list of cultures in the Windows API is slightly different from the list of cultures in the .NET Framework. For example, the neutral culture zh-CHT "Chinese (Traditional)" with culture identifier 0x7C04 is not available in the Windows API. If interoperability with Windows is required (for example, through the p/invoke mechanism), use a specific culture that is defined in the operating system. This will ensure consistency with the equivalent Windows locale, which is identified with the same LCID.



对于简体,我会坚持使用 zh-CN,而对于繁体,我可能只选择其中一个——也许您的大多数繁体用户都来自台湾?

关于.net - 中文代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/732109/

相关文章:

c# - WinForms ListView.HideSelection 属性没有效果?

c# - 如何通过代理服务器将winform连接到互联网

.net - 在 WPF 应用程序中 native 拦截按键操作的方法

c# - 在 Windows 服务中托管 ASP.NET 5 Web 应用程序

c# - 哪个更好?强制转换可为 null 的类型或使用 Value 属性检索值?

c# - 小型集合的快速数据结构

asp.net - 如何强制我的 ASP.net 2.0 应用程序重新编译

ios - 汉化

C#:如何在一个文件中读取 'éóú' 和 öäü 等字符?

ruby-on-rails - 仅在 Rails 中禁用英语的translation_missing