全球化运行时生成的程序集

发布于 2024-07-06 22:55:13 字数 558 浏览 7 评论 0原文

背景

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

问题

该项目必须全球化,作为该过程的一部分,需要提供这些文件的本地化版本。 两个选项是允许包含不同区域设置的附加 resx 文件(在同一文件中或作为附加并排文件),这些文件可以编译到主程序集的附属程序集中,或者提供每种受支持语言的每个完整文件,为受支持的语言编译适当的集。

  • 有人还有其他值得考虑的选择吗?
  • 我提出的任一解决方案可能存在哪些固有问题?

限制/免责声明
我知道情况不太理想,在某些领域可以做出更好的选择(例如从一开始就全球化),但在项目的此时点无法更改。 我感谢您提供的任何建议、解决方案或线索。 谢谢。

Background

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).

Question

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.

  • Does anyone have any other options that might be worth considering?
  • What problems might be inherent in either of the solutions I've proposed?

Constraints/Disclaimer
I am aware that the scenario is less than ideal and that better choices could've been made in some areas (like globalizing from the start), but they cannot be changed at this point in the project. I appreciate any advice, solutions, or leads you can provide. Thanks.

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

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

发布评论

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

评论(2

山有枢 2024-07-13 22:55:13

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

  • 您可以一次性构建所有程序集,并为每个版本号和文件名组合提供一个明确的文件,而不是依赖于文化。
  • 您可以在同一安装中拥有多个程序集,并根据系统语言或用户首选项等来使用要使用的语言。这将使开发和测试变得更加容易,因为您不需要不断重建和复制文件为了改变语言。
  • 这就是 .NET i18n 的工作原理。 虽然我不是 .NET i18n 方面的专家(“阅读 Guy Smith-Ferrier 的书”是我最好的建议!),但我通常发现,当您遵循框架的预期模型时,框架效果最好。

即使“构建卫星程序集”的最后一部分是在运行时完成的(您可以在安装时完成吗?),您至少仍然可以获得第二个和第三个要点优势。 这也意味着,如果您确实采用更正常的方式来提供卫星组件(而不是在用户的盒子上构建它们),那么您将需要进行的更改更少。

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

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

  • 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.

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...

北恋 2024-07-13 22:55:13

如果您不打算在部署后添加其他语言(至少在没有软件更新的情况下),那么我倾向于将所有其他 RESX 文件编译到您包含的附属程序集中。 这样,一旦部署它们,用户就无法编辑它们。

If you're not planning on adding additional languages after deployment (at least not without a software update), then I'd favor compiling all the additional RESX files into a satellite assembly that you include. That way, they're not user editable once they're deployed.

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