简体   繁体   English

全球资源翻译不起作用

[英]Global Resources translation doesn't work

I am trying to implemented App_GlobalResources for my application to support multi-language. 我正在尝试为我的应用程序实现App_GlobalResources以支持多语言。

I've created an AppGlobalResources folder, inside two files: 我在两个文件中创建了一个AppGlobalResources文件夹:

WebResources.resx
WebResources.de.resx

In each one, I put a TestString name which equals to 'test' in the default one and 'German' in the de one. 在每一行中,我都放置一个TestString名称,它的默认名称等于“ test”,而de则等于“ German”。

In the Page_Load I put the following: 在Page_Load中,我输入了以下内容:

System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de");

When I call: 当我打电话时:

txtTest.Text = WebResources.TestString;

I get the default text 'test' and not 'German' as it supposes to. 我得到默认的文本“ test”,而不是默认的“ German”。

The file properties for both resx files are: 这两个resx文件的文件属性为:

Build Action: Embedded Resource
Custom Tool: PublicResXFileCodeGenerator

Update: 更新:

I checked the WebResources.de.designer.cs and it's empty, unlike the WebResources.Deisgner.cs which has code generated for it. 我检查了WebResources.de.designer.cs,它是空的,不像WebResources.Deisgner.cs为其生成了代码。

Developing a .NET 4.6.1 web project using Visual Studio Community edition 2017. 使用Visual Studio Community Edition 2017开发.NET 4.6.1 Web项目。

The problem was that the second resx file didn't have the right build action and custom tool set. 问题是第二个resx文件没有正确的构建操作和自定义工具集。 Once I changed it, it works. 一旦更改它,它就会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM