可以在本地开发机器上为 en-EN 创建文化 [英] Can create culture for en-EN on local dev machine

查看:25
本文介绍了可以在本地开发机器上为 en-EN 创建文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我们的应用程序部署到了 azure 登台环境,但遇到了不支持 en-EN 文化的问题.经过一番挖掘,我发现没有这种文化,我应该使用 en-GBen-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-USinstead.

但是,现在我的问题.在我的本地开发机器上,我使用 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);

输出 culture: eng

我还尝试使用 CultureInfo.GetCultures(CultureTypes.AllCultures); 枚举所有文化,结果中没有相应的 en-EN 文化.

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 异常.

Starting with apps that run under the .NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException exception.

因此,基本上,您的操作系统将 en-EN 作为现有文化(更可能是 en-US)的替代名称,而它在 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.

解决方案是:使用真正的文化名称(您可以在此处找到))

The solution is: use a real culture name (which you can find here)

这篇关于可以在本地开发机器上为 en-EN 创建文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆