【问题标题】:How to only create .pot files with django manage.py makemessages如何仅使用 django manage.py makemessages 创建 .pot 文件
【发布时间】:2021-12-03 15:31:10
【问题描述】:

Weblate 有一个名为“更新 PO 文件以匹配 POT (msgmerge)”的插件。我想将 .po 文件的创建委托给 Weblate,并且只使用 manage.py makemessages 来创建 .pot 文件。

manage.py makemessages 有一个--keep-pot 选项,它将.pot 文件添加到输出中。不幸的是,没有保留.pot文件的选项。

【问题讨论】:

    标签: django gettext manage.py weblate


    【解决方案1】:

    可以通过覆盖makemessages 命令的write_po_file 方法来跳过.po 文件的创建。为此,请在management/commands 中创建一个makemessages.py 文件(如Django docs 中所述):

    # management/commands/makemessages.py
    class Command(makemessages.Command):
    
        def write_po_file(*args, **kwargs):
            """Overwrite method to do nothing.
    
            We do not want to interfere with Weblate's
            "Update PO files to match POT (msgmerge)" addon
            """
            pass
    

    【讨论】:

      猜你喜欢
      • 2014-11-28
      • 2012-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-28
      • 1970-01-01
      相关资源
      最近更新 更多