可以在本地开发机器上为en-EN创建文化 [英] Can create culture for en-EN on local dev machine
问题描述
我刚将应用程序部署到我们的azure临时环境中,遇到了一个问题,即不支持 en-EN
文化。经过一番挖掘后,我发现没有这种文化,应该使用 en-GB
或 en-US
I just deployed our application to our azure staging environment and ran into an issue with the en-EN
culture not being supported. After some digging I find out that there is no such culture, and I should use en-GB
or en-US
instead.
但是,现在是我的问题。在我的本地开发计算机上,使用 en-EN
创建 CultureInfo
没问题。
But, now to my question. On my local development machine I've got no problems creating a CultureInfo
with en-EN
.
CultureInfo ci = new CultureInfo("en-EN");
Console.WriteLine("culture: "+ ci.ThreeLetterISOLanguageName);
输出文化:英语
我还尝试使用 CultureInfo.GetCultures(CultureTypes.AllCultures);
枚举所有区域性,并且没有相应的 zh-CN
文化。
I also tried enumerating all cultures with CultureInfo.GetCultures(CultureTypes.AllCultures);
and there's no corresponding en-EN
culture in the result.
那么,这是怎么回事,为什么我要创建一种不应该存在的文化?
So, what's going on, why can I create a culture which shouldn't exist?
推荐答案
作为文档状态:
从在以下条件下运行的应用开始在Windows 7或更高版本上的.NET Framework 4或更高版本中,该方法尝试从操作系统中检索其标识符为name的CultureInfo对象。 如果操作系统不支持该区域性,并且name不是补充或替换区域性的名称,则该方法将引发CultureNotFoundException异常。
因此,基本上,您的操作系统使用 zh-CN
作为现有区域性的替代名称(更可能是 zh-CN
),而它不在Azure VM上。
So basically, your OS has en-EN
as an alternate name of an existing culture (more likely en-US
) while it's not there on the Azure VM.
解决方案是:使用真实的区域性名称(您可以找到< a href = https://msdn.microsoft.com/en-us/library/cc233982.aspx rel = nofollow noreferrer>此处)
The solution is: use a real culture name (which you can find here)
这篇关于可以在本地开发机器上为en-EN创建文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!