Why doesn't gettext have a db storage option?

前端 未结 3 1002
星月不相逢
星月不相逢 2021-02-05 23:35

I\'m doing some i18n on a web-based app using Django, which uses gettext as its i18n foundation. It seems like an obvious idea that translations should be stored in the databas

3条回答
  •  遇见更好的自我
    2021-02-06 00:15

    This seems like an obvious idea for you, I don't think everybody will agree. AFAIK django uses .po files for following reasons:

    • Version control - you will have to create additional ".po to database" tools, because you still need to maintain different people working on translations, and you can't get away from having .po files for that purpose
    • gettext is a standart way of doing translations in .nix world, there are many tools for working with it and it's simple to edit, diff, etc.
    • No need to hit database if you need to translate anything. Some views can work without any db requests, so no need to tie them to database just to get translation. (I may be wrong, but in case of mod_wsgi - translations will be loaded once and stored in memory for every thread).

    Btw, if you need to have different translations for fields, it's a bit different question and you should check http://www.muhuk.com/2010/01/dynamic-translation-apps-for-django/ and choose app that best fit your needs.

提交回复
热议问题