ASP.Net多租户SaaS应用程序中的本地化(i18N) [英] Localization (i18N) in ASP.Net Multi-tenant SaaS application

查看:94
本文介绍了ASP.Net多租户SaaS应用程序中的本地化(i18N)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其他复杂性:承租人应该能够编辑本地化的内容.因此,如果托管的应用程序有10个承租人,每个承租人支持5种语言,则最终可以得到50个单位的翻译内容.

请建议在上述情况下哪种方法更理想.

Please suggest on what would be an ideal approach given the above scenario.

下面列出的是过去(对于我的其他应用程序)使用的方法,以及为什么现在不相关:

Listed below, are approaches used in the past (for my other applications) and why they are not relevant now:

选项1: ASP.Net资源文件

Option 1: ASP.Net resource files

问题: 每个可本地化的资源(.aspx页)仅创建一种语言文件.因此,不可能为每个承租人翻译都有一个Home.aspx.resx文件. 尽管可以将resx密钥修改为包含TenantId(lblFirstName_44)并存储在相同的resx文件中,但是那样将很难维护,并且最终可能会导致文件很大.

Problem: Only one language file is created per localizable resource (.aspx page). Hence, it is not possible to have one Home.aspx.resx file for each of the tenant translations. Though the resx keys can be modified to contain the TenantId (lblFirstName_44) and stored in the same resx file, but then this would be difficult to maintain and we could end up with large files.

选项2: 在专用数据库表(标签,消息,菜单项)中存储多语言内容

Option 2: Storing multilingual content in dedicated database tables (Labels, Messages, MenuItems)

问题: 在过去(在最终用户需要动态更新可本地化内容的情况下),此方法效果很好.较早的解决方案在很大程度上依赖于缓存的数据,在多租户解决方案的情况下,数据将需要对每个页面(每个租户)进行大量缓存.缓存也可以按内容类型(标签,消息,MenuItems)进行

Problem: This has worked well in the past (in scenarios where the end user requires dynamic update of localizable content). The earlier solution relied heavily on cached data, in case of a multi-tenant solution the data would require extensive caching per page – per tenant. The caching could also be done per content type (Labels, Messages, MenuItems)

另一种方法可能是实施自定义资源提供程序(通过在.Net现有提供程序的基础上构建)

An alternate approach could be to implement a custom resource provider (by building on .Net’s existing provider)

选项3: 像FairlyLocal这样的第三方开源解决方案

Option 3: Third party open source solutions like FairlyLocal

问题: 尽管实现起来非常简单,但它具有与.resx文件相同的缺点–不适用于最终用户修改内容并维护同一文件的多个版本(按租户方式).

Problem: Although very simple to implement, suffers from the same drawback as .resx files – not designed for allowing the end user to modify the content and to maintain multiple versions (tenant-wise) of same file.

注意:如果找不到其他解决方案,我们可能会选择选项2

推荐答案

我会选择第二个选项.特别是由于您的资源条目可能会被修改,因此您无法像说的那样选择resex文件.

I'd go for the second option. Especially since your resource entries are subject to modifications, resex files are not an option as you have said.

.您可以轻松找到一个好的资源提供者,例如 westwind 或编写一个自定义提供者.

. You can easily find a good resource provider such as westwind one or write a custom provider.

这篇关于ASP.Net多租户SaaS应用程序中的本地化(i18N)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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