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

发布于 2024-07-18 18:23:45 字数 908 浏览 5 评论 0原文

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

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

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

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

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

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

  • 在 Visual Studio 中制作资源时,每个表单都应该有一个单独的资源文件(.ascx 文件),以便人们更容易并行本地化表单。
  • .ascx 文件中的 meta:resourcekey 方法非常适合本地化控件;
  • .NET 中的自动资源语言/文化回退机制应该可用;
  • 编译的结果应该是所有插件的文件都可以复制到 /MainSite/bin/Plugins/ 文件夹中。 如果每种语言/文化都有一个 .DLL 文件,并且必须将它们放入某些特定的子文件夹中 - 只要来自不同插件的 .DLL 没有冲突的名称就可以了。

关于如何实现这一目标有什么想法吗?

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

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

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.

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.

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

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.
  • The nice meta:resourcekey method in .ascx files is very comfortable for localizing controls;
  • The automatic resource language/culture fallback mechanism in .NET should be useable;
  • 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.

Any ideas on how to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丑疤怪 2024-07-25 18:23:45

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文