1

I'm building a multi-language website using ASP.NET and MVC 5. In a separate project named Resources I have a Resources.resx where all strings are kept.

From experience with a previous project I worked at, I thought that simply adding language suffixes such as "en", "es", "fr" to the Resources.resx would work. So that in the end, I would have several resources files called Resources.en.resx, Resources.es.resx and so on.

So far, I have been using only one Resources.resx file in one language, which I have had no problems with. But now it's time to start adding strings in different languages, and when I rename the file with the language suffix (and do nothing else), I can't access the resources anymore from a separate project. One thing that I have noticed is that the Resources.Designer.cs is completely blank after adding the suffix to the name, and I think this may be the root of my issue.

The answer to this question did not help as I already have set the Access Modifier for the resources as Public.

What am I missing?

Community
  • 1
  • 1
erictrigo
  • 989
  • 2
  • 13
  • 41

1 Answers1

1

When you are ready to generate resources for other languages or need to rename, use these steps https://msdn.microsoft.com/en-us/library/ms247246.aspx. Just renaming the resource file will not update Designer file for the resource

Shetty
  • 1,792
  • 4
  • 22
  • 38
  • As you said, you do need to have a different file for each language so that it knows which file to use when looking at the culture information. That's exactly my issue, that I **can't** add the language suffix to my resource file without breaking it. – erictrigo Oct 13 '15 at 15:00
  • What would break? what is the name of your resource file now? If the current name for english is Resources.resx, add another one with Resources.es.resx. Sorry if I am not understanding some here – Shetty Oct 13 '15 at 15:15
  • Maybe I didn't explain myself well enough. I have a file named `Resources.resx` in a separate project which I have been using from my project with no issues. When I change the name to `Resources.en.resx` all the references to it throughout the code get marked down in red and say "'Resources' is inaccessible due to its protection level". – erictrigo Oct 13 '15 at 15:19
  • ok. Can you check this options. http://stackoverflow.com/questions/6134419/how-to-access-another-assemblys-resx . You can see this option on top of the resource file with Name "AccessModifier" in a dropdown when you open it in Resource Editor – Shetty Oct 13 '15 at 15:21
  • It looks like renaming the resource file this way is not correct. If you rename the file, your designer file does not get changed. Check this link http://stackoverflow.com/questions/7561755/resource-files-how-to-name-them – Shetty Oct 13 '15 at 15:37
  • Look at Step 6 in the is link https://msdn.microsoft.com/en-us/library/ms247246.aspx – Shetty Oct 13 '15 at 15:40
  • Thanks to this last couple of links I realized that the issue was that I was using a suffix for ALL my resource files and the default one is supposed to not have one so that the designer file works with it. Weird, but hey, now it works. Thanks for your help, if you edit your answer, I'll select it. – erictrigo Oct 13 '15 at 15:47
  • You can have suffix for default file as well. Something like "en-US". We do use this convention in our projects – Shetty Oct 13 '15 at 15:53