views:

418

answers:

2

I'm working on an ASP.NET MVC 2 application and use a seperate class library for my model. I used resource files in my class library project to embed validation messages and use it in my meta data classes and everything was Ok till I decided to add a new language to my project so I renamed Resource.resx to Resource.en-US.resx and also copied and saved it as a new Resource.fa-IR.resx for another language but after renaming it, everything in Designer.cs companion file has been gone and I can't access Resource file anymore. As soon as I remove the language name (e.g. en-US) from filename it works properly.

I have already set Access Modifier to Public but no result.

I'm using Visual Studio 2008 SP1.

+2  A: 

Don't rename resources.resx: instead, just add resource files for the additional cultures you need.

Resources.resx contains the "neutral" resources which will be compiled into your main assembly, and used as a fallback if no satellite assembly for the required culture is located.

Each additional resource file, e.g. Resource.fa-IR.resx will normally be compiled into a culture-specific satellite assembly.

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

assembly: [System.Resources.NeutralResourcesLanguage("en-US")]
Joe
+1  A: 

You don't need to rename the default language to Resources.en-us.resx. Just keep it as Resources.resx and it will be used as a fallback resource file, meaning if no user-specific language is there, e.g. Arabic, it will be used, so, you should have the files named as following:

Resource.resx

Resource.fa-IR.resx

Hadi Eskandari