C# - How can I get the language name from the language code?
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.
精彩评论