我正在尝试将WebForm应用程序移植到MVC 6,并且遇到从resx文件获取资源的问题。控制器类中的代码仅返回默认的resx值。
我尝试设置Thread.CurrentThread.CurrentCulture
& Thread.CurrentThread.CurrentUICulture
以及将Resources.MyResouces.Culture
设置为特定文化,但Resources.MyResouces.Key
仍然只返回默认值。可能是什么问题?
public IActionResult MyAction(){
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture =
Resources.test.Culture = CultureInfo.GetCultureInfo("fr-FR");
// The line below still returns the default English resource value
var localizedValue = Resources.test.test_key;
}
答案 0 :(得分:0)
WebForms到Asp.Net Core是一个非常巨大的飞跃。我建议从GitHub上的Asp.Net Core localization sample开始,以更清楚地了解它是如何工作的。
特别是,您可能需要在Startup.cs
文件中进行更多配置。