gpt4 book ai didi

C# getCultures 在本地/currentCulture

转载 作者:太空狗 更新时间:2023-10-30 00:45:16 25 4
gpt4 key购买 nike

尽管我本地化了当前文化,但以下代码返回英文名称。

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

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

如果我希望显示名称以意大利语、德语或我指定的任何语言显示怎么办?有什么建议吗?

最佳答案

DisplayName属性以 .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)".

使用 NativeName属性(property)代替。但是,请注意,您无法获得使用不同于其自身语言的区域性名称(当然,英语和您的 .NET Framework 版本的语言除外)。

关于C# getCultures 在本地/currentCulture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5897072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com