运行 每次都需要 makemessages 吗?

Is running makemessages necessary every time?

我正在阅读 makemessages 的 django 文档,但措辞不是很清楚:

Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the Django tree) or locale (for project and application) directory. After making changes to the messages files you need to compile them with compilemessages for use with the builtin gettext support.

在上面的文字中,我似乎不清楚 makemessages 将“拉出”标记为翻译的字符串是什么意思。 (拉出来干什么?去哪儿?)

同时,compilemessages 描述很有意义,因为这只是在我更改语言文件后编译消息。

如果 compilemessages 做我正在寻找的工作,我应该什么时候使用 makemessagesmakemessages 有什么意义?

makemessages 用于扫描您的应用程序以查找标记为翻译的字符串。一旦有了这些字符串,它就会将它们放入 po 文件中。如果您随后添加更多字符串以翻译到您的应用程序,那么您将需要 运行 makemessages 来生成更新的 po 文件。 compilemessages 使用 po 文件的内容创建了一个 mo 文件,因此必须先更新 po 文件。

makemessages 接受区域设置的参数:

pipenv run django-admin makemessages --locale=de

这允许您为应用程序支持的每个语言环境创建一个 po 文件。