Global Resources translation doesn't work
Global Resources translation doesn't work
I am trying to implemented App_GlobalResources for my application to support multi-language.
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
de
In the Page_Load I put the following:
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.
The file properties for both resx files are:
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.
Developing a .NET 4.6.1 web project using Visual Studio Community edition 2017.
@ste-fu yes, same issue. BTW I checked that designer.cs file and for the de, nothing is generated, whether for the default it is.
– Idan Shechter
Sep 3 at 9:25
1 Answer
1
The problem was that the second resx file didn't have the right build action and custom tool set. Once I changed it, it works.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you tried using the string "de-DE"?
– ste-fu
Sep 3 at 9:24