Django 1.5.5始终显示原始(en)字符串(不翻译) [英] Django 1.5.5 displays original (en) strings always (does not translate)
本文介绍了Django 1.5.5始终显示原始(en)字符串(不翻译)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在模板中实现简单的Django 1.5.5字符串翻译。
I'm trying to implement simple Django 1.5.5 string translation in templates.
我有:
-
USE_I18N = True
在settings.py
-
'django.core.context_processors.i18n' code> in
settings.py
- 某些
{%transMy string%} / code>所有模板中的字符串
-
{%load i18n%}
-
python manage.py makemessages -l he
- 使用Poedit翻译我的字符串
- Ran
python manage.py compilemessages
-
LOCALE_PATHS =('conf / locale',) code>在
settings.py
- 重新启动服务器
在 settings.py中的'django.middleware.locale.LocaleMiddleware'
中 MIDDLEWARE_CLASSES
c> $
USE_I18N = True
insettings.py
'django.middleware.locale.LocaleMiddleware'
inMIDDLEWARE_CLASSES
insettings.py
'django.core.context_processors.i18n'
inTEMPLATE_CONTEXT_PROCESSORS
insettings.py
- Some
{% trans "My string" %}
strings in templates {% load i18n %}
in all templates- Ran
python manage.py makemessages -l he
- Translated my strings using Poedit
- Ran
python manage.py compilemessages
LOCALE_PATHS = ('conf/locale',)
insettings.py
- Restarted the server
翻译的字符串仍然是英语。
Translated strings remain English.
我确认当前语言是 he
在模板中使用 {%get_current_language as LANG%} {{LANG}}
。
I do check that current language is he
using {% get_current_language as LANG %}{{ LANG }}
in the template.
推荐答案
回答(从评论更新):
这似乎是一个路径问题(或者你会看到一些错误)。
It seems like a path issue (or else you'd see some error).
尝试这样做您的设定:
import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
LOCALE_PATHS = ( os.path.join(PROJECT_PATH, '../locale'), )
print LOCALE_PATHS
完全确定您的路径是否正确。
to be totally sure that you've the correct path.
也不要忘记,你需要有一个路径 locale / he / LC_MESSAGES /
django.mo(和po)文件。
Also don't forget that you need to have the path locale/he/LC_MESSAGES/
that will contain your django.mo (and po) file.
这篇关于Django 1.5.5始终显示原始(en)字符串(不翻译)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文