Gettext:源码修改后如何更新po和pot文件

问题描述 投票:0回答:3

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

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

python gettext xgettext
3个回答
20
投票

您可以查看此脚本以使用新代码更新您的 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

3
投票

使用

autoconf
automake
您可以简单地切换到
po
子目录并运行:

make update-po

或:

make update-gmo

作为包维护者,我们通常会更改为

build/po
目录并运行
update-po
。这会更新源树中的
.po
文件(假设是树外或
VPATH
构建)。然后更新的
.po
文件被提交到存储库中,在此命令之后需要准备新的提交。

update-gmo
调用会生成
.gmo
文件,这些文件通常不会提交到存储库中,这通常在构建期间自动完成。


0
投票

对于那些使用介子的人:

<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

© www.soinside.com 2019 - 2024. All rights reserved.