我正在尝试在完全信任的客户端应用程序中使用C#枚举给定Windows安装上的可用/支持语言列表。最好的方法?
答案 0 :(得分:4)
CultureInfo[] allCultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures | CultureTypes.SpecificCultures);
答案 1 :(得分:0)
怎么样
InputLanguageManager.Current.AvailableInputLanguages;
答案 2 :(得分:0)
您可以使用WMI并查询Win32_OperatingSystem类的MUILanguages属性来获取安装的可用语言集:
// There's most likely a better way to do this than using this searcher
// but it's the most reliable way I've found
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_OperatingSystem");
ManagementObjectCollection osCollection = searcher.Get();
foreach (ManagementBaseObject os in osCollection)
{
string[] languages = (string[])os.GetPropertyValue("MUILanguages");
foreach (string language in languages)
{
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(language);
Console.WriteLine(culture.EnglishName);
}
}
但是,您从中获得的语言是缩写格式,例如en-US
而不是English (United States)
。除了使用短代码和完整描述字典并查找每种语言之外,我无法看到绕过此方法来获取完整的语言字符串。