ResourceManager.GetString() method returns wrong string from different assemblies

pengibot picture pengibot · Oct 4, 2012 · Viewed 15.6k times · Source

I have 2 resource files, one with english and another foreign. When I call

ResourceManager.GetString("Hello") 

from the .Designer.cs file it is always returning the english translation. I have checked my locale and language etc. and everything is correct.

it returns properly translated strings from my main assembly, but from loaded assemblies it is always returning the english.

Answer

pengibot picture pengibot · Oct 5, 2012

Here is what was going on. I had an assembly with several translation resource files. These were all embedded resources.

When I compiled the assembly it was putting the default English inside its .dll. As for the other languages it was creating folders, fr, da, de, etc. with the languages in.

I had to move all these as well if I wanted them to be picked up by my main application which was loading in all these other assemblies. Thought as I told the assembly that they were all embedded resource files it would actually embed them!

I now have a AssemblyLoader which loads all the required .dll's when it cant find them from their current locations, packaging it will be determined on whether I want to include all languages or select the ones I want before building the project. More work than I had hoped, but solved in the end.

Anyone have any question, feel free to ask.