我正在尝试为我的应用程序实现 App_GlobalResources 以支持多语言。
我AppGlobalResources
在两个文件中创建了一个文件夹:
WebResources.resx
WebResources.de.resx
在每一个中,我TestString
在默认名称中添加了一个等于“test”的名称,在其中添加了一个等于“German”的名称de
。
在 Page_Load 我放了以下内容:
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de");
当我打电话时:
txtTest.Text = WebResources.TestString;
我得到了默认文本“测试”,而不是预期的“德语”。
两个 resx 文件的文件属性为:
Build Action: Embedded Resource
Custom Tool: PublicResXFileCodeGenerator
更新:
我检查了 WebResources.de.designer.cs 并且它是空的,不像 WebResources.Deisgner.cs 有为其生成的代码。
使用 Visual Studio Community edition 2017 开发 .NET 4.6.1 Web 项目。