全球资源翻译不起作用

问题描述 投票:0回答:1

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

c# asp.net .net app-globalresources
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.