0

After the migration to the new django version from 1.2 I have found that my localization in templates does not work. I have tried to recompile *.mo files - it's seems that translation data have been right processed but it did not helped.

May be somebody know this issue? Or may be, somebody know how to discover it? I even don't know how to reconstruct django locale environment in shell script.

How can I receive something like this in shell:

>> import django.utils.translation
>> django.utils.translation.gettext("some text that exists in locale/de/LC_MESSAGES/django.po")
>> "translated text"
Paulo Bu
  • 29,294
  • 6
  • 74
  • 73
Oleg
  • 3,080
  • 3
  • 40
  • 51
  • 1
    Watch out when you use locale in `django shell`. By default the `shell` assume en-en as the language as pointed out in this question: http://stackoverflow.com/questions/16243031/python-django-shell-ipython-unexpected-behavior-or-bug/16243631#16243631 – Paulo Bu Apr 29 '13 at 01:40
  • Seems I have found where the problem was - I sholud move locale folder to module (not to main folder). But it can be not very convinient :( – Oleg Apr 29 '13 at 08:07

1 Answers1

2

According to djangoproject documentation All paths listed in LOCALE_PATHS in your settings file are searched for <language>/LC_MESSAGES/django.(po|mo)

so you can simply add the following line to your setting.py:

LOCALE_PATHS = (PATH + "/locale",)

where PATH is main directory of your project.