如何从po文件中删除旧的(被注释掉的)msgid?

huangapple go评论131阅读模式
英文:

How to remove old (out commented) msgid from po files?

问题

在我的Python代码中,我将_("Every 30 minutes") 修改为_("Every {n} minutes").format(...)。通过使用xgettext更新pot(po模板)的工作效果很好。旧的msgid完全消失在该文件中,新的msgid出现。

但是,接下来通过使用msgmerge --update基于pot更新我的po文件让我感到困惑。旧的msgid并没有消失,而只是被注释掉了。

#~ msgid "Every 30 minutes"

我能否在某种程度上影响这种行为,防止msgmerge创建它们?

英文:

I'm quite new to the GNU gettext tools. So please feel free to correct me if I use the wrong terms.

In my Python code I modified _("Every 30 minutes") to _("Every {n} minutes").format(...).
Updating the pot (po-template) via xgettext worked well. The old msgid totally disapeared in that file and the new msgid appeared.

But then updating my po files based on the pot (using msgmerge --update) do confuse me. The old msgid do not disappear but is just out commented.

#~ msgid "Every 30 minutes"

Can I influence that behaviour somehow and prevent msgmerge from creating them?

答案1

得分: 1

我认为 msgfmt 没有这样的选项,但所有过时的条目 - 这就是它们的称呼 - 都位于文件的末尾,您可以轻松使用文本编辑器将它们删除。

过时的条目保留在 .po 文件中,因为它们随时可以重新激活,当涉及到的消息再次出现在您的源代码中时。同样,如果新字符串类似于过时的字符串,它们可以用作模糊条目的基础。出于这个原因,大多数人保留了过时的条目。

英文:

I think there is no such option to msgfmt but all obsolete entries - that is what they are called - are at the end of the file and you can easily remove them with a text editor.

Obsolete are kept in the .po file because they can always be re-activated, when the message in question re-appears in your sources. Likewise, they can be used as the base for a fuzzy entry if a new string resembles an obsolete one. Most people keep the obsolete entries for that reason.

huangapple
  • 本文由 发表于 2023年6月19日 16:18:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504828.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定