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:
The values(Just for testing):
In Resources.resx
:
In Resources.zh-CN.resx
:
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?