我正在尝试为我的应用程序实现App_GlobalResources以支持多语言。
我在两个文件中创建了一个AppGlobalResources
文件夹:
WebResources.resx
WebResources.de.resx
在每一个中,我把一个TestString
名称等于默认值中的'test'和de
中的'German'。
在Page_Load中,我提出以下内容:
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de");
我打电话的时候:
txtTest.Text = WebResources.TestString;
我得到默认文本'test'而不是它所设想的'德语'。
两个resx文件的文件属性是:
Build Action: Embedded Resource
Custom Tool: PublicResXFileCodeGenerator
更新:
我检查了WebResources.de.designer.cs并且它是空的,不像Web Resources.Designer.cs那样为它生成了代码。
使用Visual Studio Community Edition 2017开发.NET 4.6.1 Web项目。
问题是第二个resx文件没有正确的构建操作和自定义工具集。一旦我改变它,它的工作原理。