Given a list of cultures, I want to retrieve their display names based on a culture other than my own. Using "en", "de" and "fr" querying CultureInfo for them on my machine (US version of Windows 10 set to culture "en-ZA") gives the following result.
de => { EnglishName="German", NativeName="Deutsch", DisplayName="German" }
en => { EnglishName="English", NativeName="English", DisplayName="English" }
fr => { EnglishName="French", NativeName="français", DisplayName="French" }
I would like to retrieve names matching the arguments and lists below
de => { Deutsch, Englisch, Französisch }
en => { German, English, French }
fr => { allemand, Anglais, français }
Note that these may be slightly incorrect as I had assistance from Google Translate, but I think you'll get the idea.
I had hoped I might simply be able to set the culture for the thread before retrieving the DisplayName as follows.
CultureInfo myCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de");
string english = CultureInfo.GetCultureInfo("en").DisplayName; // hoped for "Englisch"
string french = CultureInfo.GetCultureInfo("fr").DisplayName; // hoped for "Französisch"
string german = CultureInfo.GetCultureInfo("de").DisplayName; // hoped for "Deutsch"
Thread.CurrentThread.CurrentCulture = myCulture;
But this does not work and in each case DisplayName for any culture is always the same as EnglishName.
Is there something I'm missing in .NET (or even a third-party library) that can help me get what I need or am I going to have to build hard-coded lists? I would like to avoid that as I currently need this for around 30 languages and more could be added at any time.