Monday, February 27, 2012

Re: internationalization makemessage don't work

On Mon, Feb 27, 2012 at 7:19 PM, Denis Darii <denis.darii@gmail.com> wrote:
> Of course, from the django
> documentation(https://docs.djangoproject.com/en/dev/topics/i18n/translation/#message-files):
>>
>> The script should be run from one of two places:
>>
>> The root directory of your Django project.
>> The root directory of your Django app.
>>
>> The script runs over your project source tree or your application source
>> tree and pulls out all strings marked for translation.
>
>
> So "The script runs over your project source tree or your application source
> tree"...
>
>
> On Mon, Feb 27, 2012 at 11:03 PM, nicolas HERSOG <n.hersog@gmail.com> wrote:
>>
>> I've already tried this, django created LC_MESSAGE folder in locale, but
>> this folder is empty (no django.po file is generated :/)
>>
>> I'm guessing if the problem is not the way i tagged the things to
>> translate ...
>> I added to all the html files i wanted to translate the tag {% load i18n
>> %} and all the strings i wanted to translate are between {%trans
>> "myStringToTranslate" %}
>>
>> Is the fact that my /template folder is not in the same path than m apps
>> may be a problem ?
>>
>>
>> On Mon, Feb 27, 2012 at 10:58 PM, Denis Darii <denis.darii@gmail.com>
>> wrote:
>>>
>>> Hi Nicolas.
>>> Try to run makemessages script from the root directory of your Django
>>> app, so:
>>>
>>> $ cd /your/app/path/
>>> $ mkdir locale
>>> $ django-admin.py makemessages -l en
>>>
>>>
>>>
>>> On Mon, Feb 27, 2012 at 10:54 PM, nicolas HERSOG <n.hersog@gmail.com>
>>> wrote:
>>>>
>>>> Yes, I have my app in INSTALLED_APPS and I also have added this key in
>>>> my settings :
>>>>
>>>> USE_I18N = True
>>>> USE_L10N = True
>>>>
>>>> MIDDLEWARE_CLASSES = (
>>>>     'django.middleware.common.CommonMiddleware',
>>>>     'django.contrib.sessions.middleware.SessionMiddleware',
>>>>     'django.middleware.csrf.CsrfViewMiddleware',
>>>>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>>     'django.contrib.messages.middleware.MessageMiddleware',
>>>>     'debug_toolbar.middleware.DebugToolbarMiddleware',
>>>> )

I'm not completely sure about this, but I think you should try adding
'django.middleware.locale.LocaleMiddleware' to your MIDDLEWARE_CLASSES.
You should pay attention to the order, though.
LocaleMiddleware should be put after SessionMiddleware and before
CommonMiddleware.

Here's a snippet from a working example:

MIDDLEWARE_CLASSES = (
'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',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)


diego

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment