gpt4 book ai didi

python - 将复数形式生成到 .pot 文件中

转载 作者:行者123 更新时间:2023-11-28 16:55:11 27 4
gpt4 key购买 nike

我正在对 python 程序进行国际化,但无法将复数形式添加到 .pot 文件中。我用 _pl() 标记了需要复数翻译的字符串,例如。

self.write_info(_pl("%(num)d tracks checked", "%(num)d tracks checked",
song_obj.song_count) % {"num": song_obj.song_count})

然后我在运行:xgettext --language=Python --keyword=_pl --output=output.pot *.pypot 文件中仅生成第一个(单数)字符串。

最佳答案

我还没有在 Python 中使用过它,目前无法测试,但可以试试 --keyword=_pl:1,2

来自 GNU gettext docs :

--keyword[=keywordspec]’ Additional keyword to be looked for (without keywordspec means not to use default keywords).

If keywordspec is a C identifier id, xgettext looks for strings in the first argument of each call to the function or macro id. If keywordspec is of the form ‘id:argnum’, xgettext looks for strings in the argnumth argument of the call. If keywordspec is of the form ‘id:argnum1,argnum2’, xgettext looks for strings in the argnum1st argument and in the argnum2nd argument of the call, and treats them as singular/plural variants for a message with plural handling.

关于python - 将复数形式生成到 .pot 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/711637/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com