开发者

C# - How can I get the language name from the language code?

开发者_JS百科

I'm looking for a way to get the language name from the language code.

en -> English
zh -> Chinese
jp -> Japanese
fr -> French
de -> German

etc...


Console.WriteLine(new CultureInfo("en").DisplayName);

Note that DisplayName will format the name for the currently set language. If you want it to always be in English, use EnglishName.


Something like this will work:

var allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
var en = allCultures.FirstOrDefault (c => c.Name == "en").DisplayName;
var de = allCultures.FirstOrDefault (c => c.Name == "de").DisplayName;

CultureInfo.DisplayName will contain what you are looking for.


I just found this: http://www.csharp-examples.net/culture-names/

not sure if it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜