2

I'm trying to enable translations for a django project and django-admin.py makemessages -l de doesn't seem to create any .po files, although there is a couple of {% trans ... %} in templates and a couple of gettext(...) in models for tests. Accorgin to the documentation https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-makemessages, the command should search for translations in the whole project tree and create corresponding files in e.g. conf/locale directory if no setting is specified. The only output I get is processing locale ru.

Any way to debug it or maybe well known pitfalls that I didn't find in google?

Alexander
  • 1,299
  • 2
  • 12
  • 32

2 Answers2

5

Let me answer my own question :)

The problem was that I:

  1. Didn't import gettext as _ but did import gettext as t, thus makemessage didn't recognize translated strings in .py files
  2. Tried to translate non-existing variables in templates instead of strings. {% trans some_var %} instead of {% trans "some_string" %}
Alexander
  • 1,299
  • 2
  • 12
  • 32
0

Make sure you have the following settings available in your settings.py file:

DJANGO_ROOT = dirname(dirname(abspath(__file__)))
SITE_ROOT = dirname(DJANGO_ROOT)
USE_I18N = True

LOCALE_PATHS = (
    SITE_ROOT + '/locale',
)

If the LOCALE_PATHS value is not set it does not know where it should create the locale directories and translation files, also you don't have to have the DJANGO_ROOT and SITE_ROOT values that's just for ease of use.

Alex Carlos
  • 882
  • 5
  • 7
  • I have it like this in settings.py: `BASE_DIR = os.path.dirname(os.path.dirname(__file__)) LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )` – Alexander Oct 04 '14 at 08:37