我正在努力使我的MVC项目本地化,并与我们现有的用于编辑字符串资源的基础设施一起工作。我们将所有的资源字符串存储在数据库表中,并有一个用于编辑它们的前端web UI和一个生成.resx文件的导出应用程序。这一切都很好,但我有一个新的项目使用MVC2和VS2010有点困难。
another question
在这个问题上,我几乎得到了答案,但不完全是。
Build Action = Embedded Resource
Copy to Output Directory = Do not copy
Custom Tool = PublicResXFileCodeGenerator
Custom Tool Namespace = Resources
File Name = MyApp.resx
我已将导出应用程序更改为运行
resgen.exe
具有以下参数的工具。。。
string args = string.Format("/publicClass \"{0}\" /str:cs,Resources,{1},\"{2}\"", resourceFile, Path.GetFileNameWithoutExtension(resourceFile), csFilename);
生成的.designer.cs文件与在导出应用程序中运行resgen.exe工具时得到的文件略有不同。
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Resources.MyApp", typeof(MyApp).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
... 运行resgen.exe工具时的区别是前缀
MyCompany.MyApp公司
到ResourceManager的构造函数中的命名空间
new global::System.Resources.ResourceManager("MyCompany.MyApp.Resources.MyApp", typeof(MyApp).Assembly);
资源
,不是
.
那么,这个问题有解决方法吗?
目前我唯一能想到的就是用powershell对生成的.designer.cs文件进行后期处理并修复它!