数据库级的国际化 [英] Internationalization on database level

查看:133
本文介绍了数据库级的国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以指出一些解决国际化数据库级任务的模式吗?

Could anyone point me to some patterns addressing internationalization on the database level tasks?

最简单的方法是为每个文本列的每种语言添加一个文本列,但这是有点臭 - 真的我想有能力动态添加支持的语言。

The simplest way would be to add a text column for every language for every text column, but that is somehow smelly - really i want to have ability to add supported languages dynamically.

我要使用的解决方案是保存在模型中的一种主要语言,以及查询翻译和保存的翻译的字典实体。

The solution i'm coming to is one main language that is saved in the model and a dictionary entity that gets queried for translations and saved translations to.

所有我想要的是听到其他人这样做。

All i want is to hear from other people who have done this.

推荐答案

您可以创建一个包含三列的表格:目标语言代码,原始字符串,翻译字符串。表上的索引将在前两列,但我不会将此表绑定到其他具有外键的表。您需要为每个运行的查询中需要翻译的每个字词添加一个连接(可能是一个左连接,以记录错过的翻译)。但是,这会使你的所有查询都非常毛茸茸,并且可能会影响性能。

You could create a table that has three columns: target language code, original string, translated string. The index on the table would be on the first two columns, but I wouldn't bind this table to other tables with foreign keys. You'd need to add a join (possibly a left join to account for missing translations) for each of the terms you need to translate in each query you run. However, this will make all your queries very hairy and possibly kill performance as well.

另一件你需要注意的事实是翻译术语,最新翻译表。

Another thing you need to be aware of is actually translating the terms and maintaining an up-to-date translation table. This is very inconvenient to do directly against the database and is often done by non-technical people.

通常在本地化应用程序时,你会使用类似 gettext 。这套工具背后的想法是解析可以解析源代码以提取字符串进行翻译,然后从中创建翻译文件。由于这个套件已经存在了很长时间了,有很多不同的实用程序基于它,有助于翻译任务,其中之一是 Poedit ,一个不错的GUI编辑器,将字符串翻译成不同的语言。生成唯一的术语列表可能更简单,因为它们在数据库中以gettext可以解析的格式出现,并在应用程序代码中进行翻译。这样,您就可以使用相同的方法来对应用程序中的硬编码字符串和数据库值进行翻译。

Usually when localizing an application you'd use something like gettext. The idea behind this suite of tools is to parse can parse source code to extract strings for translation and then create translation files from them. Since this suite has been around for a long time, there are a lot of different utilities based on it that help with the translation task, one of which is Poedit, a nice GUI editor for translating strings into different languages. It might be simpler to generate the unique list of terms as they appear in the database in a format gettext could parse, and do the translation in the application code. This way you'd be able to do the translation of the hard coded strings in the application and the database values using the same technique.

这篇关于数据库级的国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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