开发者

The best/recommended way to translate Django database values

I'm trying to figure out the best way to translate actual database values (textual strings, not date formats or anything complicated) when开发者_Python百科 internationalizing my Django application. The most logical ways I could come up with were to either:

  • hold a database column for every language (e.g. description_en, description_de, description_fr, ...) or
  • have a different database for every language (e.g. schema_en, schema_fr, schema_de, ...).

Are these the best options, or is there something else I'm missing? Thanks.


I was reading up on my django extensions, and found the django-modeltranslation plugin. It seems to do exactly what you want it to do.


I also found this small project which purpose is to synchronize localized strings into standard message files for fields of registered models.

Example:

import vinaigrette
vinaigrette.register(YourModel, ['name', 'description'])

The standard command

$ manage.py makemessages

Would maintain messages for each distinct values found in registered fields.

I have not had the occasion to try it yet.
But this seems for me to be the simplest way to translate data from db.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜