微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c#:在一个dotnet类中有一个属性,说明“当前”文化是否真的是默认文化?

某些课程中是否有某个属性可以告诉我当前的文化是否真的是认文化.

类似于本地化与winforms的工作方式.如果语言是认的,它会在表单中声明.

让我们说如果我在en-US – 我怎么能通过代码告诉en.US是否是实际的认值?

我需要为.net不支持的某些XML文件实现一些本地化,因此我想实现自己的…

并且做winforms如何工作,即

nameofxml.default.xml (this is the default local)
nameofXml.de-de.xml (this is german) 

等等

财产存在吗?

解决方法

System.Globalization.CultureInfo.CurrentCulture表示系统的控制面板区域设置,而System.Globalization.CultureInfo.CurrentUICulture对应于系统的输入UI语言设置(除非安装了多语言用户界面,否则无法更改).

因此,您可以使用以下代码段来确定“认”文化:

using System.Globalization;
// N.B. execute the following line *before* you programmatically change the CurrentCulture
// (if you ever do this,of course)

// Gets the CultureInfo that represents the culture used by the current thread
CultureInfo culture = CultureInfo.CurrentCulture;
string code = culture.IetfLanguageTag; // e.g. "en-US","de-DE",etc.

然后,您可以使用该代码来查找.xml文件.

原文地址:https://www.jb51.cc/csharp/100019.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐