Question

I have various language resource files in this format: MyApplication\Resources\MyForm\Index.resx

I can access the current cultured resource files okay. However, if I want to find a different culture resource file (say, Index.de.resx), I am struggling to find a way to get to it.

ci = new System.Globalization.CultureInfo("de");
rm = new ResourceManager("MyApplication.Resources.MyForm", Assembly.GetExecutingAssembly());
lg = rm.GetString("Lang", ci);      

The error I get says:

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyApplication.Resources.MyForm" was correctly embedded or linked into assembly "BallotApplication" at compile time, or that all the satellite assemblies required are loadable and fully signed.

My resources files are public and the Build Action is "Embedded Resource".

Was it helpful?

Solution

Your resource file is correctly named, however, you're not setting the full and correct CultureInfo.

It needs to be the full name I.E de-DE

The full code breaks down as the language (de) part and country (DE) part, separated by the - hyphen.

ci = new System.Globalization.CultureInfo("de");

Should be

ci = new System.Globalization.CultureInfo("de-DE");

Other examples would be:

  1. en-US = English US
  2. en-CA = English Canada
  3. en-GB = English Great Britain
  4. fr-CA = French Canada
  5. fr-FR = French France

More info on the CultureInfo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top