使用 MVC ASP.NET 进行复杂本地化

发布于 2024-11-25 04:18:40 字数 558 浏览 1 评论 0原文

目前,我们为网站设置了 Web 表单,并希望慢慢将其转换为 MVC。目前我们将翻译存储在数据库中。我们的翻译表包含每种语言的列和一种标题。我们可以用它来识别翻译(主键),

但是当我们实际上可能有不同的客户想要对同一文本位使用不同的单词时,情况就会变得更加复杂。

例如,人们希望它读作“交付成本” 下一个可能需要它作为 - 交付价格

因此,我们有第二个 CustomTranslation 数据表,它将与翻译相同,但其中也有一个客户 ID 号。如果用户登录并查找翻译标识为“DeliveryCost”,它将检查 CustomTranslation 表中是否有记录,它将在标准翻译表上使用该记录。

之后它将选择用户想要的适当语言。

基本上我需要能够根据用户设置来翻译我们的网站。以及他们工作的公司(我们的客户)

本地化的一般方法使用资源文件,但我们需要将它们真正保存在数据库中。这产生了第二个问题,即当您尝试声明属性显示名称和验证消息时,它们也需要能够具有不同的文本和/或翻译,但通常它需要一个我们不会有的静态字段。

解决这个复杂的本地化问题的最佳方法是什么?

提前致谢。史蒂夫

We currently have a Web Forms set up for our website and are looking to slowly convert this to MVC. Currently we store translations in a database. our translation table contains columns for each language and a sort of title. which we can identify the translation with(The primary key)

But it gets more complex when we actually may have different clients wanting different words for the same bit of text.

E.g. one will want it to read - Delivery Costs
And the next may want it as - Delivery Prices

So we then have a second CustomTranslation datatable which will be the same as the translation but also have a client ID number in it. If the user logged in and it looking for the Identify of the translation as "DeliveryCost" it will check to see if there is a record in the CustomTranslation table it will use that OVER the standard Translation table.

After which it will then pick the appropriate language the users wants.

Basically I need to be able to have our website translate depending on the users settings. And as well as the company they work for (our client)

The general method of localization uses resource files but we need to really keep them in the database. This produces a second problem which is when you try to declare Propertry Display Names and Validation Messages these also need to ability to have different text and/or translations but generally it expects a Static field which we would not have.

Whats the best way to go about solving this complex localization issue?

Thanks in advance. Steve

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

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

发布评论

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

评论(1

记忆里有你的影子 2024-12-02 04:18:40

问题 1 - 数据库中有资源
使用 这篇文章用于将标准资源扩展到数据库中。

问题 2 - 为每个客户提供自定义本地化
没问题,标准 .net 方法支持本地化,包括区域或客户,只需使用 ie en-US、en-US-Customer1、en-US-Customer2 等即可。

Problem 1 - Having the resources in the database
Use the approach used in this article for extending the standard resources into the database.

Problem 2 - Having custom localization per customer
No problem, the standard .net approach supports localization including a region or customer, just use i.e. en-US, en-US-Customer1, en-US-Customer2, etc.

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