我有这种格式的各种语言资源文件:MyApplication\Resources\MyForm\Index.resx
我可以访问当前培养的资源文件。但是,如果我想找到不同的文化资源文件(例如,Index.de.resx
),我很难找到获取它的方法。
ci = new System.Globalization.CultureInfo("de");
rm = new ResourceManager("MyApplication.Resources.MyForm", Assembly.GetExecutingAssembly());
lg = rm.GetString("Lang", ci);
我得到的错误是:
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.
我的资源文件是公开的,Build Action 是“Embedded Resource”。
最佳答案
您的资源文件已正确命名,但是,您没有设置完整且正确的 CultureInfo
。
需要是全名I.E de-DE
完整代码分为语言 (de
) 部分和国家 (DE
) 部分,由 -
连字符分隔。
ci = new System.Globalization.CultureInfo("de");
应该是
ci = new System.Globalization.CultureInfo("de-DE");
其他例子是:
en-US
= English USen-CA
= 加拿大英语en-GB
= English Great Britainfr-CA
= 加拿大法语fr-FR
= 法语法国
有关 CultureInfo 的更多信息.
关于asp.net - 访问不同培养的资源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13630064/