设置之后,CultureInfo.DefaultThreadCurrentUICulture CultureInfo.DisplayName总是返回英语。
我试着
CultureInfo cu = new CultureInfo("ja-JP");
System.Threading.Thread.CurrentThread.CurrentCulture = cu;
CultureInfo.DefaultThreadCurrentCulture = cu;
// CultureInfo.DefaultThreadCurrentUICulture = cu;
// SetDefaultCulture(cu);
Dictionary<string, string> ifile = new Dictionary<string, string>();
var regex = new System.Text.RegularExpressions.Regex(@"([\w+\s*\.*]+\))");
foreach (var item in CultureInfo.GetCultures(CultureTypes.FrameworkCultures))
{
I18nCulture country = new I18nCulture();
var match = regex.Match(item.DisplayName);
string countryName = match.Value.Length == 0 ? item.EnglishName : match.Value.Substring(0, match.Value.Length - 1);
if (item.Name != "")
{
ifile.Add(item.Name, item.DisplayName);
}
}
string fn = System.IO.Path.Combine(rootPath, "lib", "i18n", "culture", lng + ".json");
Console.WriteLine("save : " + fn);
saveObjectToJSON(ifile, fn);当我运行这段代码时,item.DisplayName是用德语编写的,这是我当前的os系统语言。当我取消评论时,CultureInfo.DefaultThreadCurrentUICulture = cu; item.DisplayName是用英语写的。此时,我希望看到显示名称的ja-JP版本。
如何获取线程当前区域性中的区域性显示名称?
发布于 2017-03-24 21:44:11
您必须安装日语.NET框架语言包。
https://stackoverflow.com/questions/43009128
复制相似问题