[英]python django translation .po and .mo file not translating the files
I am trying to create a project using for 2 languages german and English 我正在尝试创建一个使用2种语言的德语和英语项目
My Settings File 我的设置文件
LOCALE_PATHS = (os.path.join(BASE_DIR, 'app /locale'),)
MIDDLEWARE = (
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
How I am running this tool 我如何运行此工具
python manage.py makemessages -a
This tool runs in debug mode
processing locale en
processing locale de
python manage.py compilemessages
This tool runs in debug mode
processing file django.po in app/locale/de/LC_MESSAGES
processing file django.po in app/locale/en/LC_MESSAGES
File Location app_ac/locale/de/LC_MESSAGES 文件位置app_ac / locale / de / LC_MESSAGES
-rw-rw-r--. 1 root root 421 May 11 11:44 django.mo
-rw-rw-r--. 1 root root 44K May 11 11:43 django.po
I am not getting the desired translations, I feel might be something is going wrong in .mo file as the size is just 421bytes as comparted to .po file which is 44Kb 我没有得到所需的翻译,我觉得.mo文件可能出了问题,因为与.po文件相比,大小仅为421bytes,它是44Kb
EDIT 1 编辑1
I have just figured out that in django.po file 我刚刚在django.po文件中弄清楚了
The file looks like this 该文件看起来像这样
#: project/settings.py:184
msgid "German"
msgstr ""
#: project/settings.py:185
msgid "English"
msgstr ""
Instead of (What would ideally be, Sorry for my poor German) 而不是(理想情况下,对不起我可怜的德国人)
#: .\project\settings.py:185
msgid "German"
msgstr "Deutsch"
#: .\project\settings.py:186
msgid "English"
msgstr "Englisch"
我只是想知道po文件中缺少翻译消息,将它们替换为适当的消息,然后运行python manage.py compilemessages
命令,现在翻译就像一个魅力!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.