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

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

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

etc...

+3
source share
3 answers
Console.WriteLine(new CultureInfo("en").DisplayName);

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

+16
source

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

not sure if this helps.

0
source

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.

0
source

Source: https://habr.com/ru/post/1791114/


All Articles