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

标签 python internationalization xgettext

我正在对 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 *.py pot 文件中仅生成第一个(单数)字符串。

最佳答案

我还没有在 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/

相关文章:

python - Pandas - 在每日人口普查数据中查找唯一条目

php - 只需要 xgettext 生成的翻译字符串,而不是源文件中的所有字符串

c++ - 使用带有 --extract-all 的 xgettextt 处理复数

php - xgettext 给了我一个简单的行 : 的奇怪输出

Python yaml 输出 - 浮点精度?

python - 如何将图像添加到我的博客文章中?

python - 如何让 Python 程序通过下载和安装/更新所需的所有库来修复自身?

java:rest api 中的时区

javascript - 多语言支持

ruby-on-rails - Rails i18n 特定的错误验证格式