0

我正在尝试为我的应用程序实现 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 项目。

4

1 回答 1

0

问题是第二个 resx 文件没有正确的构建操作和自定义工具集。一旦我改变它,它就可以工作。

于 2018-09-03T09:30:53.013 回答