[英]ASP.NET - why is the default resx file being used in the code-behind when the localized one is being used by the markup?
我正在用C#创建一个ASP.NET Web应用程序,并且必须将该应用程序本地化为英语和法语。 我创建了两个资源文件:App_GlobalResources \\ Resources.resx和App_GlobalResources \\ Resources.fr.resx,其中包含英语和法语内容。
当我在浏览器设置为法语(fr_FR)的情况下运行该应用程序时,法语内容会正确显示在标记中。
在后台代码中,当我从资源访问值时,它仅返回默认的英语值。 例如
this.CompanyName.Text = string.Format(App_GlobalResources.Resources.CompanyLocationsFormat,companyName);
调试该应用程序将显示CurrentCulture和CurrentUICulture都正确设置为fr_FR。
谁能解释我如何获取背后的代码以使用适合当地文化的资源文件?
非常感谢
(C#,ASP.NET 3.5 SP1,Visual Studio 2008,IE 8.0.7600)
您确定法语资源文件中存在此特定资源(CompanyLocationsFormat)吗? 如果缺少资源,它将恢复为默认资源。
在web.config的<system.web>
部分中是否有此功能?
<globalization culture="auto" uiCulture="auto" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.