【问题标题】:Gettext : How to update po and pot files after the source is modifiedgettext : 修改源后如何更新po和pot文件
【发布时间】:2011-09-21 07:34:23
【问题描述】:

我有一个带有国际化字符串的 python 项目。 我修改了源代码,字符串的行也发生了变化,即在 pot 和 po 文件中,字符串的行没有指向正确的行。

那么如何将 po 和 pot 文件更新到文件中的新字符串位置。

【问题讨论】:

    标签: python gettext xgettext


    【解决方案1】:

    您可以查看this script 以使用新代码更新您的 po 文件。它使用xgettextmsgmerge

    echo '' > messages.po # xgettext needs that file, and we need it empty
    find . -type f -iname "*.py" | xgettext -j -f - # this modifies messages.po
    msgmerge -N existing.po messages.po > new.po
    mv new.po existing.po
    rm messages.po
    

    【讨论】:

    • 您将我需要的两个命令合二为一真是太好了。 +1
    • @Manu : 有一个gettext for windows
    【解决方案2】:

    使用autoconfautomake,您可以简单地切换到po 子目录并运行:

    make update-po
    

    或:

    make update-gmo
    

    【讨论】:

      【解决方案3】:

      对于使用介子的人:

      <project_id>-pot<project_id>-update-po

      例如对于iputils 项目:

      $ dir="/tmp/build"
      $ meson . $dir && ninja iputils-pot -C $dir && ninja iputils-update-po -C $dir
      

      来源:https://mesonbuild.com/i18n-module.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-25
        • 2012-04-22
        • 1970-01-01
        • 2012-01-16
        • 2011-06-08
        • 2020-01-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多