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".
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:
en-US
= English USen-CA
= English Canadaen-GB
= English Great Britainfr-CA
= French Canadafr-FR
= French FranceMore info on the CultureInfo.