0

The first and second question are solved. I keep them for being a reference for the unsolved third question.

Original Question

Original title: Cannot create a resource designer and access resource strings with different locales?
I want to localize my project and some problems came up.
My current resource files are like this:
2.png
The values(Just for testing):
In Resources.resx:
5.png
In Resources.zh-CN.resx:
6.png

First Question

I cannot run the custom tool(PublicResXFileCodeGenerator) for Resources.zh-CN.resx but I can run the same tool for Resources.resx
Why?

Second Question

The following code

Properties.Resources.Culture = CultureInfo.GetCultureInfo("zh-CN");
Console.WriteLine(Properties.Resources.HelloWorld);

will print "Hello World!" instead of the expected result "你好世界!" as defined in Resources.zh-CN.resx
How can I print the expected result?

-----Update-----

I solved the above questions by myself but the way I solved it confused me and I have no idea what fixed it.
In my solution I have three projects and the resources are in the library project which is depended by the other two projects. Where I try to print the string is from the console project in this solution.
If I move the resource files to the console project it works well.
However I need the resource files be shared in the library project by the other two.
So, here comes the third question.

Third Question

Now I wonder why this happens? And how can I access the resource files from other projects in a solution correctly?

Qiufeng54321
  • 169
  • 11
  • I could see that the "Resources.zh-CN.resx" doesn't have the c# file attached. How you added the "Resources.zh-CN.resx" to the code? – Sathish Guru V Feb 07 '20 at 08:59
  • @SathishGuru File->New->File->Resource Files. I cannot find Resource Files option in Add->New Item. And I cannot generate the c# file using the custom tool, as described in the first question. – Qiufeng54321 Feb 07 '20 at 09:09
  • Based on your description, you can refer to [How to use shared resource file between projects in one solution?](https://stackoverflow.com/a/10334095/11507778) to know how to access the resource files from other projects in a solution. – Jack J Jun Feb 11 '20 at 06:39

0 Answers0