Problem with language resource files in a class library project

I am working on an ASP.NET MVC 2 application and use a separate class library for my model. I used resource files in my class library project to insert validation messages and use them in my metadata classes, and everything was fine until I decided to add a new language to my project, so I renamed Resource.resx to Resource.en-US. resx also copied and saved it as a new Resource.fa-IR.resx for another language, but after renaming it, everything in the comparion file of Designer.cs disappeared and I can no longer access the resource file. As soon as I remove the language name (e.g. en-US) from the file name, it works correctly.

I already installed an access modifier for sharing, but no result.

I am using Visual Studio 2008 SP1.

+5
source share
2 answers

Do not rename resources.resx: instead, just add resource files for the additional cultures that you need.

Resources.resx contains “neutral” resources that will be compiled into your main assembly and used as a reserve if the satellite assembly for the required culture is not assembled.

Each additional resource file, for example. Resource.fa-IR.resx will usually be compiled into a satellite assembly related to culture.

You can also add to AssemblyInfo.cs NeutralResourcesLanguageAttribute, which tells the ResourceManager of the language you used for neutral resources:

assembly: [System.Resources.NeutralResourcesLanguage("en-US")]
+6

Resources.en-us.resx. Resource.resx, , , . , , :

Resource.resx

Resource.fa-IR.resx

+2

All Articles