在ASP.NET多语言战略咨询 [英] Advice on ASP.NET Multi-Lingual Strategy

查看:172
本文介绍了在ASP.NET多语言战略咨询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人会分享他们的想法是,让使用.NET动态多语言系统的最佳策略,他们的经验

I am wondering if anyone would share their experience on what they think as the best strategy to enable dynamic multi-lingual system using .NET

我有一个客户谁希望有一个半MRP系统,存储所有产品的材质和规格。这些信息将在以后用于其他模块,如发票,采购,市场营销(提取印刷目的的信息)等等。

I have a customer who wishes to have an semi-MRP system that stores all Product's Materials and specs. These information will later be used for other modules such as Invoices, Purchasing, Marketing (extracting the information for printing purposes) and many more.

事情是,他希望一切都可以存储多国语言。他也无法固定的语言数量。因此,语言的数量将在整个时间增长。

The thing is, he wants everything to be stored multiple languages. He is also unable to fixed the number of languages. Hence, the number of languages will grow throughout time.

所以,我想什么,我问的是,什么是设置的最佳策略的动态语言启用的网站,包含的字段名称(如姓名),也它的数据(例如,拉斯克)。

So I guess what I am asking is, what is the best strategy to setup a dynamic language enabled website that encompasses the field names (eg, name) and also it's data (eg, Lasker).

非常感谢,
拉斯克

Many thanks in advance, Lasker

推荐答案

有几种可供选择。


首先,到标签和UI元素

下面一般有两种可能的选择,无论你使用的资源(*的.resx)或推出在数据库级别上你自己的多语言支持。他们都有自己的优点和缺点。

Here are generally two options possible, you either use resources (*.resx) or roll out your own multilingual support on the database level. They both have their advantages and disadvantages.

Resoures:

[+]简单的解决方案,一切准备就绪后立即使用。 c您参考这些字符串你定义一个名为家庭像 Orders.en.resx,Orders.fr.resx 等。在$ C $文件的文本资源作为 Resources.Orders.Title 。所以它是一个简单的解决方案的静态的用户界面元素。

[+] Easy solution, everything is ready for immediate use. You define a textual resource in a family of files named like Orders.en.resx, Orders.fr.resx etc. In code you reference these strings as Resources.Orders.Title. So it is a simple solution for static elements of UI.

[+]资源文件是可快速读取和分析,所以基本上简单的XML文档没有太大的开销,或性能损失。

[+] Resource files are basically simple XML documents that can quickly be read and parsed, so not much overhead or performance loss.

[ - ]如果你需要改变一些东西,你就必须重新编译该项目。这进而意味着你需要安装的人谁可能会考虑更新文本的开发环境(VS)。然后,您还需要重新部署编译版本。这同样适用于引进新的语言到系统中。

[-] If you need to change something, you will have to recompile the project. That consequently means you will need the development environment (VS) installed for anyone who may consider updating texts. Then, you will also need to deploy the recompiled version again. The same applied for introduction of new languages into the system.

[ - ]。不会对非技术性的东西工作,因为需要专家参与

[-] Will not work for non-technical stuff, since participation of specialists required.

自定义数据库驱动的多语言解决方案:

[ - ]将需要一些时间和精力来设计和实施

[-] Will require some effort and time to design and implement

[ - ]每一个UI文本将从数据库,这意味着性能下降和额外的负载在数据库上拉

[-] Every single UI text will be pulled from the database, which means performance drop and extra load on the database

[+]将允许文本和删除/添加新的语言的动态上的即时变化。无需重新编译或部署是必需的。

[+] Will allow dynamic on-the-fly change of texts and deletion/addition of new languages. No recompilation or deployment will be required.

[+] 现在一个巨大的加分。由于没有技术技能都需要在文本工作,你可以外包这项工作的任何位置。你可以实现一个Web界面和变更跟踪系统,专业的翻译服务,商店,纠正你的文本和执行转换到你急需新的文本被发现后的任何语言​​。

[+] Now a huge plus. Since no technical skills are required to work on texts, you can outsource this work to any location. You may implement a web interface and change tracking system for professional translation service shops to correct your texts and perform translations to any language you need quickly after new texts are discovered.


现在到动态文本(实际内容)。

在这里,您可以拆分每个文本存储在某些表或所有的翻译合并成一个单一的实体,每个语种一个额外的记录。

Here you can either split each text to be stored as an extra record per language in some table or to merge all translations into a single entity.

多个记录:

试想以下数据库模型:

[Language]
-----------------
ID    Description

[Translation]
------------------
ID    FallbackText

[TranslationText]
--------------------------------
ID    TRID    LanguageID    Text

[Order]
------------------------------------------------
ID    TitleTRID    DescriptionTRID    RemarkTRID

到处在您需要存储多语言文本数据库,反而会涉及到一些TranslationID。然后依赖于积极的语言,你的系统会寻找适当的翻译,或者,如果没有找到,返回一个默认的文本(通常由开发人员设置)。

Everywhere in the database where you need to store a multilingual text, you will instead reference some TranslationID. Then dependent on the active language, you system will look for an appropriate translation or, if not found, return a default text (usually set by developers).

单一的实体:

您保持在一个字符串给定文本的翻译都用显着的特定翻译一些手段。 XML自然在这里工作。

You keep all translations for a given text in one string by using some means of distinguishing particular translations. XML naturally works here.

<translation>
  <en>Order</en>
  <de>Bestellung</de>
  <fr>Commande</fr>
</translation>

在这里,您的数据库模型会更简单,但你需要解析每一个文本中提取所需要的版本。

Here you database model will be simpler but you will need to parse every single text to extract the needed version.


这些是广泛使用的策略。哪一个最适合您将取决于您的需求和预期的使用场景。

These are the widely used strategies. Which one will work best for you will depend on your needs and your expected usage scenarios.

希望有所帮助。 :)

这篇关于在ASP.NET多语言战略咨询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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