我在 Django 中有一个现有的应用程序。 我想在页面上添加翻译。 在我的页面上:
{% trans 'Projects'%}
在我添加的.po文件中:
#: templates/staff/site.html: 200
msgid "Projects"
msgid "Projekty"
然后执行命令:
django-admin.py compilemessages -l pl
执行此命令后,出现错误:
CommandError: This Should Be Run script from the Django Git checkout or your project or app tree, or with the settings Specified module.
最佳答案
$ python manage.py compilemessages --settings nsp.settings
CommandError: This script should be run from the Django Git checkout or your project or app tree, or with the settings module specified.
当我真的在项目根文件夹中时,我遇到了这个错误。
问题是,我在没有先使用 python manage.py makemessages
的情况下运行此命令。
错误信息具有误导性。
关于python - 在 Django 中翻译文件时的 Git 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29027242/