django makemessages-CommandError:运行msguniq时发生错误-语法错误

时间:2019-03-26 23:34:15

标签: python django translation

我在Windows 7操作系统上使用django 1.10.5和python 3.6.5。

我有一个具有现有翻译字符串的测试应用。

makemessages命令在过去有效。

但是,在上周尝试运行django-admin makemessages命令时,收到了以下错误:

(myappenv36) C:\Users\me\desktop\myapp\myapp [master ≡ +0 ~13 -0 !]> dja
ngo-admin makemessages
CommandError: errors happened while running msguniq
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783:3: syntax error
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783: keyword "core" un
known
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783: keyword "models"
unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783: keyword "py" unkn
own
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783: keyword "core" un
known
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783: keyword "models"
unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1783: keyword "py" unkn
own
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1785: keyword "core" un
known
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1785: keyword "models"
unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:1785: keyword "py" unkn
own
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4543:3: syntax error
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4543: keyword "template
s" unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4543: keyword "base" un
known
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4543: keyword "resume_m
enu" unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4543: keyword "html" un
known
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4545: keyword "template
s" unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4545: keyword "header"
unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4545: keyword "header"
unknown
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4545: keyword "html" un
known
C:\Users\me\desktop\myapp\myapp\locale\django.pot:4548: keyword "template
s" unknown
msguniq: too many errors, aborting

我已经在Google和SO上进行了彻底的搜索,以找到此问题的答案,但我还是空白。

这些是我为解决此问题所做的尝试:

1。。遵循django 1.10 docs,并重新安装了该download中的gettext。

2。。从我的语言环境目录中移走了所有.po和.mo文件,并尝试在空的翻译文件上运行django-admin makemessages。这给了我同样的错误信息。

任何人都可以让我深入了解错误消息以及如何解决此问题吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

对我来说,我的 # 文件中这一行前面缺少一个 django.po

: .\my_project\templates\base.html:114

做完之后:

$ django-admin makemessages --locale 'de_DE' --ignore=venv/*

错误代码:

#: .\my_project\templates\account\signup.html:9
#: .\my_project\templates\account\signup.html:19
: .\my_project\templates\base.html:114
msgid "Sign Up"
msgstr "Registrieren"

好的代码:

#: .\my_project\templates\account\signup.html:9
#: .\my_project\templates\account\signup.html:19
: .\my_project\templates\base.html:114
msgid "Sign Up"
msgstr "Registrieren"