开发者

Naming convention for internationalized (i18n) database fields

What is the 'best pr开发者_如何学Cactice' naming convention for internationalized database fields? In the current code base, the convention is to use the '_id' suffix for foreign key fields. But if a field is internationalized, should we append an '_i18n' suffix to the field? EG: 'label_i18n' as opposed to 'label'? Pros and cons?


If you're doing i18n, then you should have a separate table storing the fields.

E.g.

Table Fields (blogpost):
- id, INT (10)
- user_id, INT(10)

i18n table (blogpost_i18n):
- blogpost_id, INT(10)
- title, VARCHAR(255)
- content, TEXT
- lang, VARCHAR(10)

where the lang column stores the i18n code for that language, this way you can add as many languages as you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜