문제

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?

도움이 되었습니까?

해결책

You should use the NativeName property

Look at this question also How to translate CultureInfo language names

다른 팁

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top