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

165 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

Selenite Vingt-Neuf

غير مقروءة،
30‏/05‏/2014، 12:57:40 م30‏/5‏/2014
إلى django...@googlegroups.com
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

visionary800

غير مقروءة،
30‏/05‏/2014، 9:15:34 م30‏/5‏/2014
إلى django...@googlegroups.com
My recent experience with using django-admin.py makemessages is that this command only works when there is a subdirectory present named 'locale' that sits just below where you are executing this command.  Without a 'locale' subdirectory present, the command will raise an error.  I think by design it only makes translation files for the user created project/apps.  You can exclude parts of your project.


I am not sure if that helped.
الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة