ASP.NET Web表单资源和本地化的棘手问题

时间:2022-03-25 04:11:21

I've got the following nonstandard setup (VS2008, .NET 3.5 SP1):

我有以下非标准设置(VS2008,.NET 3.5 SP1):

There is a main web project called MainSite and There are several "plugin" web projects with different names.

有一个名为MainSite的主要Web项目,有几个名称不同的“插件”Web项目。

When building these plugins I have a custom build step that calls aspnet_compiler.exe and aspnet_merge.exe. This results in two .DLL files - plugin_name.dll and plugin_name_deploy.dll. The first one contains the codebehind classes, the second one contains code generated from .ascx files.

在构建这些插件时,我有一个自定义构建步骤,它调用aspnet_compiler.exe和aspnet_merge.exe。这会导致两个.DLL文件 - plugin_name.dll和plugin_name_deploy.dll。第一个包含代码隐藏类,第二个包含从.ascx文件生成的代码。

These plugin .DLL's are then copied to /MainSite/bin/Plugins/ folder. At runtime (application startup) MainSite application looks in this folder and dynamically loads all the .DLL files there.

然后将这些插件.DLL复制到/ MainSite / bin / Plugins /文件夹。在运行时(应用程序启动),MainSite应用程序在此文件夹中查找并动态加载所有.DLL文件。

All my forms are in the plugins, in .ascx files. The main application is just a skeleton which loads these .ascx usercontrols as needed.

我的所有表单都在.ascx文件的插件中。主要应用程序只是一个骨架,可根据需要加载这些.ascx用户控件。

And now comes the need for localization. Ideally I would like to have the following:

现在需要本地化。理想情况下,我希望有以下内容:

  • When making the resources in Visual Studio, there should be a separate resource file for every form (.ascx file) so that it is easier for people to localize the forms in parallel.
  • 在Visual Studio中创建资源时,每个表单(.ascx文件)都应该有一个单独的资源文件,以便人们更容易并行地本地化表单。

  • The nice meta:resourcekey method in .ascx files is very comfortable for localizing controls;
  • .ascx文件中的好的meta:resourcekey方法非常适合本地化控件;

  • The automatic resource language/culture fallback mechanism in .NET should be useable;
  • .NET中的自动资源语言/文化回退机制应该是可用的;

  • The result of compilation should be such that the files from all the plugins can be copied to the /MainSite/bin/Plugins/ folder. If there is a .DLL file for every language/culture and they hav to be put in some specific subfolders - that's fine as long as the .DLLs from different plugins don't have colliding names.
  • 编译结果应该是所有插件中的文件都可以复制到/ MainSite / bin / Plugins /文件夹中。如果每个语言/文化都有一个.DLL文件,并且它们可以放在某些特定的子文件夹中 - 只要不同插件的.DLL没有碰撞名称就可以了。

Any ideas on how to achieve this?

关于如何实现这一点的任何想法?

1 个解决方案

#1


Apparently it is possible to implement custom resource providers in .NET. Here is an article that contains links to various other articles that explain the whole process. In effect, you take the value from meta:resourcekey and get the value from wherever you want. The article above, for example, stores all localization information in a DB.

显然,可以在.NET中实现自定义资源提供程序。这篇文章包含解释整个过程的各种其他文章的链接。实际上,您从meta:resourcekey获取值,并从您想要的任何位置获取值。例如,上面的文章将所有本地化信息存储在DB中。

#1


Apparently it is possible to implement custom resource providers in .NET. Here is an article that contains links to various other articles that explain the whole process. In effect, you take the value from meta:resourcekey and get the value from wherever you want. The article above, for example, stores all localization information in a DB.

显然,可以在.NET中实现自定义资源提供程序。这篇文章包含解释整个过程的各种其他文章的链接。实际上,您从meta:resourcekey获取值,并从您想要的任何位置获取值。例如,上面的文章将所有本地化信息存储在DB中。