在Django中翻译文件时使用Git命令

mar*_*ark 4 python django translation

我在Django中有一个现有的应用程序.我想在页面上添加翻译.在页面上我有:

{% trans 'Projects'%}
Run Code Online (Sandbox Code Playgroud)

在.po文件中我添加了:

#: templates/staff/site.html: 200
msgid "Projects"
msgid "Projekty"
Run Code Online (Sandbox Code Playgroud)

然后执行命令:

django-admin.py compilemessages -l pl
Run Code Online (Sandbox Code Playgroud)

执行此命令后,出现错误:

CommandError: This Should Be Run script from the Django Git checkout or your project or app tree, or with the settings Specified module.
Run Code Online (Sandbox Code Playgroud)

sob*_*evn 11

[11:08:21] sobolev :: MacBook-Pro-Nikita➜文档/ PyCharmProjects/nsp <master*>»python manage.py compilemessages --settings nsp.settings2↵CommandError:这个脚本应该从Django Git运行结帐或您的项目或应用树,或指定的设置模块.

当我真正进入项目根文件夹时,我遇到了这个错误.问题是,我没有python manage.py makemessages先运行此命令.

错误消息具有误导性.


Hed*_*ide 5

错误包含答案,您可以从任何地方运行脚本,因此它无法知道要编译哪些文件。从项目目录运行命令或指定设置,你应该没问题。