有没有办法让自定义 CultureInfo 翻译 RegionInfo?
我尝试了以下方法,但它不起作用:
/* Change culture of current thread to german*/
CultureInfo de = new CultureInfo("de");
Thread.CurrentThread.CurrentCulture = de;
Thread.CurrentThread.CurrentUICulture = de;
RegionInfo regionInfoDe = new RegionInfo("de");
regionInfoDe.DisplayName.Should().Be("Deutschland");
/* Change culture of current thread to englisch */
CultureInfo en = new CultureInfo("en");
Thread.CurrentThread.CurrentCulture = en;
Thread.CurrentThread.CurrentUICulture = en;
RegionInfo regionInfoEn = new RegionInfo("de");
regionInfoEn.DisplayName.Should().Be("Germany");
如果当前文化是德语,我想从 RegionInfo("de") 中获取“Deutschland”。如果当前的文化是英语,应该是“德国”。