The best/recommended way to translate Django database values

前端 未结 3 1780
陌清茗
陌清茗 2020-12-13 19:47

I\'m trying to figure out the best way to translate actual database values (textual strings, not date formats or anything complicated) when internationalizing my Django appl

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 20:04

    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.

提交回复
热议问题