Friday, May 30, 2014

makemessages doesn't understand I'm reusing Django existing translation messages

Hi,

I'm writing authentication templates using authentication views provided by Django, and for that purpose I am reusing translation messages present in django.contrib.admin.

That works very well at the execution time, Django understands that translation messages already exist in django.contrib.admin and display them in the requested language (French in my case).

My concern is that "django-admin.py makemessages -a" command doesn't understand just as well and it creates those translation messages again in my auth app's locale files. But I don't need them, or at least commented as #fuzzy. Is it the normal behavior of that command or am I doing wrong ?

Below is the example with the message "Reset my password":

In django.contrib.admin locale files:

- path/to/python2.7/sites-packages/django/contrib/admin/locale/en/LC_MESSAGES/django.py

#: templates/registration/password_reset_form.html:21
msgid "Reset my password"
msgstr ""
 
- path/to/python2.7/sites-packages/django/contrib/admin/locale/fr/LC_MESSAGES/django.py

#: templates/registration/password_reset_form.html:21
msgid "Reset my password"
msgstr "Réinitialiser mon mot de passe"

In my password_reset template of my auth app:

- auth/templates/auth/password_reset.html:

{% load i18n %}

<input type="submit" value="{% trans "Reset my password" %}" />


In my auth app's locale files after typing "cd path/to/myproject; cd auth; django-admin.py makemessages -a":

- auth/locale/en/LC_MESSAGES/django.po:

#: templates/auth/password_reset.html:36
msgid "Reset my password"
msgstr ""

- auth/locale/en/LC_MESSAGES/django.po:

#: templates/auth/password_reset.html:36
msgid "Reset my password"
msgstr ""

Here my settings:

- myproject/settings.py:

MIDDLEWARE_CLASSES = (
    'django.middleware.cache.UpdateCacheMiddleware',
    '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.cache.FetchFromCacheMiddleware',
)

LANGUAGE_CODE = 'en-us'

LANGUAGES = (
    ('fr', _('French')),
    ('en', _('English')),
)

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

Here my config:

- Mac OS X 10.9.2
- python 2.7.6
- gettext 0.18.3 (installed via homebrew)

Thanks for your help.

Cheers,

Selenite Vingt-Neuf

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d95b17f0-650d-4bc6-8209-ab38fb6ca34e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment