我们正在将旧的 .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/