Django 1.5.5始终显示原始(en)字符串(不翻译) [英] Django 1.5.5 displays original (en) strings always (does not translate)

查看:185
本文介绍了Django 1.5.5始终显示原始(en)字符串(不翻译)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在模板中实现简单的Django 1.5.5字符串翻译。

I'm trying to implement simple Django 1.5.5 string translation in templates.

我有:


  1. USE_I18N = True settings.py

  2. settings.py中的'django.middleware.locale.LocaleMiddleware' MIDDLEWARE_CLASSES c> $
  3. 'django.core.context_processors.i18n' code> in settings.py

  4. 某些 {%transMy string%} / code>所有模板中的字符串

  5. {%load i18n%}
  6. python manage.py makemessages -l he

  7. 使用Poedit翻译我的字符串

  8. Ran python manage.py compilemessages

  9. LOCALE_PATHS =('conf / locale',) code>在 settings.py

  10. 重新启动服务器

  1. USE_I18N = True in settings.py
  2. 'django.middleware.locale.LocaleMiddleware' in MIDDLEWARE_CLASSES in settings.py
  3. 'django.core.context_processors.i18n' in TEMPLATE_CONTEXT_PROCESSORS in settings.py
  4. Some {% trans "My string" %} strings in templates
  5. {% load i18n %} in all templates
  6. Ran python manage.py makemessages -l he
  7. Translated my strings using Poedit
  8. Ran python manage.py compilemessages
  9. LOCALE_PATHS = ('conf/locale',) in settings.py
  10. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆