简体   繁体   English

多语言翻译模块的数据库模型

[英]Database model for a multilanguage translation module

I need to design a db model for a backend module where user can translate page content into multiple languages. 我需要为后端模块设计一个数据库模型,用户可以在其中将页面内容翻译成多种语言。 The things that will be translated are basic words, phrases, link names, titles, field names, field values. 将要翻译的内容是基本单词,短语,链接名称,标题,字段名称,字段值。 They should also be grouped so i can find them by group name. 它们也应该分组,以便我可以通过组名找到它们。 For example if there is a select field on page with different colors as options then i should be able to select all of them by group name. 例如,如果页面上有一个带有不同颜色的选择字段作为选项,那么我应该能够通过组名选择所有这些字段。

So here is what i have at the moment: 所以这是我现在所拥有的:

lang
+----+---------+
| id |  name   |
+----+---------+
|  1 | english |
|  2 | german  |
+----+---------+

lang_entity
+----+------------+-------------+-------+-------+
| id |   module   |    group    | name  | order |
+----+------------+-------------+-------+-------+
|  1 | general    |             | hello |     0 |
|  2 | accounting | colorSelect | one   |     1 |
|  3 | accounting | colorSelect | two   |     2 |
|  4 | accounting | colorSelect | three |     3 |
+----+------------+-------------+-------+-------+

lang_entity_translation
+----+---------+----------------+-------------+
| id | lang_id | lang_entity_id | translation |
+----+---------+----------------+-------------+
|  1 |       1 |              1 | Hello       |
|  2 |       2 |              1 | Guten tag   |
|  3 |       1 |              2 | One         |
|  4 |       2 |              2 | Ein         |
|  5 |       1 |              3 | Two         |
|  6 |       2 |              3 | Zwei        |
|  7 |       1 |              4 | Three       |
|  8 |       2 |              4 | Drei        |
+----+---------+----------------+-------------+

So lang table holds different languages. 因此lang表包含不同的语言。

Table lang_entity has entities that can be translated for different languages. 表lang_entity具有可以转换为不同语言的实体。 Module row is just to group them by page modules in the backend translating module. 模块行只是将它们按后端翻译模块中的页面模块分组。 Also this gives me possiblity to have entities with same name for different modules. 这也使我有可能让不同模块具有相同名称的实体。 Group as mentioned is needed for selects and maybe some other places where multiple values are going to be used. 选择和某些其他可能需要使用多个值的地方需要上述分组。 This also gives me an option to allow user to add and order entities in one group. 这也为我提供了一个选项,允许用户在一组中添加和订购实体。

And table lang_entity_translation holds the translations for each entity in each language. 表lang_entity_translation包含每种语言在每个实体的翻译。

So my question is are visible flaws in this kind of a design? 所以我的问题是这种设计是否存在明显的缺陷? Would you reccomend something different? 你会推荐不同的东西吗?

Also a bonus question: I really dont like the lang_entity table name, do you have a better idea of a table name that would hold all the words/phrases that are translated? 还有一个额外的问题:我真的不喜欢lang_entity表名,您对表名有一个更好的主意,该表名可以容纳所有已翻译的词/短语吗? :) :)

Edit: similar, but not a duplicate. 编辑:相似,但不是重复。 The linked question is about translating dynamic products and having a seperate table for each translated type. 链接的问题是有关翻译动态产品并为每种翻译类型提供单独的表。 Im talking about translating whole page content, including groups in a single table. 我说的是翻译整个页面的内容,包括单个表中的组。

We had similar situation. 我们有类似的情况。 This was 7 years before. 这是七年前。 We had different column for different language. 对于不同的语言,我们有不同的专栏。 Like for name we had Name_Eng,Name_Ger,Name_Spa .We had 7-10 language. 就像名字一样,我们有Name_Eng,Name_Ger,Name_Spa。我们有7-10种语言。

We had common id for name for all language. 我们对于所有语言的名称都有通用的ID。

Based on the Language selection from UI we passed the language code to Back end In the Stored proc it was appended to the column Name Example, we will be passing "Eng" if English is selected and we form the column name as Name_Eng and fetch the data. 根据用户界面中的语言选择,我们将语言代码传递给了后端。在存储过程中,将其附加到名称示例列中,如果选择了英语,我们将传递“ Eng”,并且将列名称形成为Name_Eng并获取数据。 we were using dynamic query. 我们正在使用动态查询。

I don't understand the order column of lang_entity , but then I probably don't need to. 我不了解lang_entityorder列,但那时我可能不需要。

The setup looks sane, but make sure you add foreign key constraints from lang_entity_translation to language and lang_entity . 该设置看起来很合理,但是请确保将从lang_entity_translation添加到languagelang_entity外键约束。

As for naming, I would call the table phrase or translatable . 至于命名,我将其称为表phrase或可translatable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM