VS的.resx VS数据库定制解决方案的提供本地化/全球化 [英] .resx vs database vs custom solution for providing Localization/Globalization

查看:124
本文介绍了VS的.resx VS数据库定制解决方案的提供本地化/全球化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的办公室,我们已经收到了本地化/全球化以及如何处理它的争论由来已久。一边推了内置于ASP.NET资源(的.resx)文件路径,一面推动为一个数据库驱动的解决方案。第三组认为,在滚动一个定制的解决方案。

At my office, we have had a long-standing debate about Localization/Globalization and how to handle it. One side pushes for the Resource (.resx) file route built in to ASP.NET, one side pushes for a database driven solution. A third group believes in rolling a custom solution.

当然,每种方法都有其独特的优点和缺点 - 我们已经一遍又一遍地讨论过,从来没有来一个真正的共识

Of course, each method has its own unique benefits and disadvantages - and we've discussed it over and over, without ever coming to a real consensus.

所以,我把它构成了对社区:在你的经验,随着应用的增长,该方法提供了以下的最佳组合:

So, I pose it to the community: in your experience, which method provides the best mix of the following as the application grows:


  1. 可维护性

  2. 扩展

  3. 性能/可扩展性

除了刚才的意见,我们也希望有兴趣任何开源项目,其中可能有助于简化问题,以及。谢谢!

In addition to just advice, we'd also be interested in any open source projects which might help to simplify the question, as well. Thanks!

推荐答案

里克·斯特劳(一个MS MVP)具有通过DB管理本地化一个伟大的工具包 - 提供通过受控的环境中进行更新,并根据需要修改能力和做很多繁重的你。 Histoolkit提供以下功能:

Rick Strahl (An MS MVP) has a great tool kit for managing localization via the DB - offer the ability to update and modify on demand through a controlled environment and does much of the heavy lifting for you. Histoolkit offer the following features:

数据驱动的本地化资源提供者

Data Driven Localization Resource Provider


  • 数据库驱动的本地化可以让您存储资源在SQL Server数据库中。

  • 基于资源Adminstration交互式Web提供了一个实时的基于Web的adminstration可以编辑和更新资源的应用程序运行时

  • 资源编辑控制关联与每个本地化控制图标,并允许直接跳到与当前选定的资源ID和区域的管理形式。

  • RESX导入和导出可以导入现有的资源RESX,交互与数据驱动的供应商进行编辑,然后抽出导出早在RESX资源。

  • 本地化工具像一个JavaScript资源处理程序,功能嵌入本地化的脚本值等等。​​

他也在这里总结了问题很好(IVE粘贴一些好位在这里 - 不我自己的工作!)

He also summarises the issues very well here (Ive pasted some good bits here - not my own work!)

要RESX或不RESX

在.NET中的默认资源存储机制
  使用基于RESX资源。 RESX指的XML文件扩展
  充当原始输入资源文件是本机
  。净。尽管XML是您在视觉看到输入存储格式
  工作室和.resx文件,最后的资源的格式是一二进制
  这被编译成.NET程序集格式(的.resources)
  编译器。这些编译资源可以存储与旁边
  code二进制组件或它们在资源卫星自己
  组件,其唯一目的就是提供资源。通常,在
  .NET固定区域性资源嵌入到基地
  存储组件与设在卫星装配任何其他文化
  在特定文化的子目录。

The default resource storage mechanism in .NET uses Resx based resources. Resx refers to the file extension of XML files that serve as the raw input for resources that are native to .NET. Although XML is the input storage format that you see in Visual Studio and the .Resx files, the final resource format is a binary format (.Resources) that gets compiled into .NET assemblies by the compiler. These compiled resources can be stored either alongside with code in binary assemblies or on their own in resource satellite assemblies whose sole purpose is to provide resources. Typically in .NET the Invariant culture resources are embedded into the base assembly with any other cultures housed in satellite assemblies stored in culture specific sub-directories.

如果你正在使用Visual Studio
  资源的编译过程是pretty多少自动 - 当你
  添加一个.resx文件到项目VS.NET自动编译
  资源和嵌入他们进入组件并创建卫星
  与为每个所需的目录结构沿装配
  支持的语言环境。 ASP.NET 2.0通过进一步此基础上扩展的过程
  自动化资源服务模型和自动编译
  被发现App_GlobalResources文件和RESX资源
  App_LocalResources文件并将它们提供给一个应用
  资源提供者这是特定于ASP.NET。资源提供者
  使资源访问从ASP.NET中更容易和更一致
  应用程序。

If you’re using Visual Studio the resource compilation process is pretty much automatic – when you add a .Resx file to a project VS.NET automatically compiles the resources and embeds them into assemblies and creates the satellite assemblies along with the required directory structure for each of the supported locales. ASP.NET 2.0 expands on this base process by further automating the resource servicing model and automatically compiling Resx resources that are found App_GlobalResources and App_LocalResources and making them available to the application with a Resource Provider that’s specific to ASP.NET. The resource provider makes resource access easier and more consistent from within ASP.NET apps.

在.NET框架本身使用的.resx资源服务
  本地化内容如此看来理所当然的工具
  框架提供使资源创建工具提供服务
  同样的模式。

The .NET framework itself uses .Resx resources to serve localized content so it seems only natural that the tools the framework provides make resource creation tools available to serve this same model.

RESX作品不够好,但它不是很灵活
  当涉及到实际编辑的资源。该工具支持
  Visual Studio是真的挺不足以支持本地化
  因为VS不提供一种简单的方法交叉参考资源
  在多个语言环境。虽然ASP.NET的设计编辑器可以帮助
  与最初产生的资源页面上的所有控制 - 通过
  在生成本地资源工具 - 它仅适用于数据
  默认不变文化​​的RESX文件。

Resx works well enough, but it’s not very flexible when it comes to actually editing resources. The tool support in Visual Studio is really quite inadequate to support localization because VS doesn’t provide an easy way to cross reference resources across multiple locales. And although ASP.NET’s design editor can help with generating resources initially for all controls on a page – via the Generate Local Resources Tool – it only works with data in the default Invariant Culture Resx file.

RESX资源是亦静
   - 他们毕竟编译成汇编。如果你想
  更改资源,您将需要重新编译看到这些变化。
  ASP.NET 2.0引入了可存储全局和本地资源
  在服务器上,可以动态更新 - ASP.NET的编译器
  实际上可以在运行时编译它们。但是,如果你使用
  precompiled Web部署模型的资源仍然最终被
  静态的,不能在运行时改变。所以,一旦你与完成
  汇编的资源是固定的。

Resx Resources are also static – they are after all compiled into an assembly. If you want to make changes to resources you will need to recompile to see those changes. ASP.NET 2.0 introduces Global and Local Resources which can be stored on the server and can be updated dynamically – the ASP.NET compiler can actually compile them at runtime. However, if you use a precompiled Web deployment model the resources still end up being static and cannot be changed at runtime. So once you’re done with compilation the resources are fixed.

在运行时更改资源
  似乎不是什么大不了的事,但它可以在很方便
  资源本地化进程。那岂不是很好,如果你可以编辑
  在运行时的资源,做出改变,然后居然看到这种变化
  在UI立刻?

Changing resources at runtime may not seem like a big deal, but it can be quite handy during the resource localization process. Wouldn’t it be nice if you could edit resources at runtime, make a change and then actually see that change in the UI immediately?

使用数据库资源

这使我想到了存储资源
  数据库。数据库是由自然更具活力,可以使
  而不必重新编译的变化数据库中的数据
  应用。此外,数据库中的数据更容易被共享
  多个开发商和本地化,以便更容易进行修改,
  资源在团队环境中。

This brings me to storing resources in a database. Databases are by nature more dynamic and you can make changes to data in a database without having to recompile an application. In addition, database data is more easily shared among multiple developers and localizers so it’s easier to make changes to resources in a team environment.

当你想想资源
  编辑它基本上是一个数据录入任务 - 你需要仰视
  单独的资源价值,看到所有的不同的语言变体
  然后添加,并为每个不同的区域设置的编辑值。
  虽然所有的这可能是与在RESX文件的XML来完成
  直接它实际上更容易前端建立一个数据库
  比XML文件散落得到处都是。数据库也给你
  更大的灵活性,以显示在不同视图中的资源数据
  并可以很容易地做这样的事情批量更新和密钥的重命名
  和值。

When you think about resource editing it’s basically a data entry task – you need to look up individual resource values, see all the different language variations and then add and edit the values for each of the different locales. While all of this could be done with the XML in the Resx files directly it’s actually much easier to build a front end to a database than XML files scattered all over the place. A database also gives you much more flexibility to display the resource data in different views and makes it easy to do things like batch updates and renames of keys and values.

好消息是,在.NET中的资源方案是
  不固定的,你可以扩展它们。 .NET和ASP.NET 2.0允许你
  创建自定义的资源管理器(核心.NET运行时)和资源
  供应商(ASP.NET 2.0),从任何地方,包括了服务资源
  的一个数据库中。

The good news is that the resource schemes in .NET are not fixed and you can extend them. .NET and ASP.NET 2.0 allow you create custom resource managers (core .NET runtime) and resource providers (ASP.NET 2.0) to serve resources from anywhere including out of a database.

这篇关于VS的.resx VS数据库定制解决方案的提供本地化/全球化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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