全球化运行时生成的程序集 [英] Globalizing runtime generated assemblies

查看:73
本文介绍了全球化运行时生成的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个项目会安装一些包含所有元素的文件来定义UserControl-一些用户源代码,一个用于设计器代码的CodeCompileUnit ,以及一个resx文件。在运行时,这些文件被编译为一个程序集,并且这些类由我们的主应用程序使用(该程序集仅在必要时更新)。

A project installs some files that contain all the elements to define a UserControl - some user source, a CodeCompileUnit for designer code, and a resx file. At runtime, these files are compiled into an assembly and the classes are consumed by our main application (the assembly is only updated when necessary).

该项目必须进行全球化,并且作为该过程的一部分,需要对这些文件进行本地化。有两种选择:要么允许包含不同语言环境的其他resx文件(在同一文件中,要么作为其他并排文件),可以将其编译为主程序集的附属程序集,或者提供以下内容的副本:每个支持的语言的完整文件,为支持的语言编译适当的集合。

The project has to be globalized and as part of that process, there is a need to provide localizations of these files. Two options are either to allow the inclusion of additional resx files for different locales (either within the same files or as additional side-by-side files) that can be compiled into a satellite assembly for the main assembly, or to provide a copy of each full file for each supported language, compiling the appropriate set for the language being supported.


  • 任何人还有其他可能值得的选择吗?正在考虑吗?

  • 我提出的两种解决方案中可能都存在哪些固有问题?

约束/免责声明

我知道这种情况不太理想,可以选择更好的选择是在某些领域进行的(例如从一开始就进行全球化),但是目前无法在项目中更改它们。我感谢您可以提供的任何建议,解决方案或线索。谢谢。

推荐答案

为每种文化创建一个单独的附属程序集。这有两个好处:

Create a separate satellite assembly for each culture. This has two benefits:


  • 您可以一次性构建所有程序集,并为每个版本号和文件名组合使用一个确定的文件,而不是取决于文化。

  • 您可以在同一安装中具有多个程序集,并根据系统语言使用该语言,或者用户首选项等。这将使开发和测试变得更加容易,因为您不必为了更改语言而一直在重建和复制文件。

  • .NET就是这样i18n专为工作而设计。虽然我不是.NET i18n的专家(我最好的建议是读Guy Smith-Ferrier的书!),但我通常会发现,当遵循框架的预期模型时,框架最有效。

  • You can build all of the assemblies in one go, and have a definitive file for each version number and filename combination, rather than it also depending on the culture.
  • You can have multiple assemblies in the same installation, and base the language to use on the system language, or a user preference etc. This will make development and testing significantly easier, as you won't need to keep rebuilding and copying files around just for the sake of changing languages.
  • It's how .NET i18n is designed to work. While I'm not an expert on .NET i18n ("read Guy Smith-Ferrier's book" is my best advice!) I generally find that frameworks work best when you follow their expected model.

即使构建附属程序集的最后部分在运行时完成了(您可以在 install 时完成吗?),您仍然会得到第二和第三点的优点至少。这也意味着,如果您走更常规的提供卫星组件的路线(而不是在用户的盒子上建造它们),您的更改就更少了。

Even if the final part of "building the satellite assembly" is done at runtime (can you do it at install time instead?) you still get the second and third bullet advantages at least. It also means that if you ever do go the more normal route of supplying the satellite assemblies to start with (instead of building them on the user's box) you'll have less to change.

很抱歉,如果我误解了这个问题...

Apologies if I've misunderstood the question though...

这篇关于全球化运行时生成的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆