Question

The following code returns English names despite I localized the currentculture.

List<string> languageList = new List<string>();
CultureInfo[] cultureList = CultureInfo.GetCultures(CultureTypes.AllCultures);

    foreach (CultureInfo culture in cultureList)
    {
        languageList.Add(culture.DisplayName);
    }

What if I want the display names say in Italian, or in German or whatever language I specify? Any suggestions?

Was it helpful?

Solution

You should use the NativeName property

Look at this question also How to translate CultureInfo language names

OTHER TIPS

The DisplayName property returns the culture name in the language of the localized version of the .NET Framework:

This property represents the localized name from the .NET Framework version. For example, if the .NET Framework English version is installed, the property returns "English (United States)" for the en-US culture name. If the .NET Framework Spanish version is installed, regardless of the language that the system is set to display, the culture name is displayed in Spanish and the property for en-US returns "Ingles (Estados Unidos)".

Use the NativeName property instead. However, note that you cannot obtain a culture name in a language different than its own (except, of course, English and the language of your version of the .NET Framework).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top