我正在学习数据库国际化,并且有一个“小”问题。
我有一个名为categories
的表,其中包含字段id
、name
、description
等。并且,表 products
具有字段 id
、category_id
、name
、description
> 还有其他人。
categories table
id | name | description | ...others
和
products table
id | category_id | name | description | ...others
我需要国际化这些(和其他)表。因此,开始方法是创建另外三个表并更改第一个表。
languages table
id | name | code
categories table
id | ...others
category_languages table
id | category_id | language_id | name | description
products table
id | category_id | ...others
product_languages table
id | product_id | language_id | name | description
嗯,主要问题是:有办法将本地化“集中”在一个表中吗?我忘记了什么?
谢谢!
最佳答案
您可以在一个表中添加翻译标签和翻译,然后将翻译标签添加到每个表中的新列中。您将有一个名为“translations”的表,其中 id 列可以是标签和翻译列:
id | label | translation | language_id
在每个表中:
id | some columns | translation_label
关于mysql - 表字段国际化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12885730/