[Tutor] django-python Version 1.1.1 - Internacionalization
andré palma
andrefsp at gmail.com
Thu Nov 12 05:09:03 CET 2009
Hi all!
I'm developing a django web application but i'm having a trouble with
the internationalization.
The problem is that translation somehow doesn't work.
i followed these steps:
- on my project folder (./translation ) i run the command:
"django-admin makemessages -l en-US"
and it created the follow file with the right content:
./mysite/locale/en-US/LC_MESSAGES/django.po
inside the file it shows the messagesId's and the related messages
strings to fill with the translation. I was glad to see gettext is
installed.
========================
#: views.py:12
msgid "benvindo"
msgstr "welcome"
========================
this messageID is related with this view:
=================================================
from django.utils.translation import ugettext as _
def translate1(request):
output = _("benvindo")
return HttpResponse(output)
#("code from djangobook")
=================================================
- then i run "django-admin compilemessages" and so it has created the
binary file ./mysite/locale/en-US/LC_MESSAGES/django.mo, as i expected.
I think i already have my settings.py file configured and it looks like
this:
=======================================================================
LANGUAGE_CODE = 'en-US'
# gettext settings for translation
ugettext = lambda s: s
LOCALE_PATHS = (
'/home/andrefsp/django/mysite/locale',
)
LANGUAGES = (
('pt-PT', ugettext('Portuguese')),
('en-US', ugettext('English')),
)
USE_I18N = True
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
========================================================================
And it still isn't working =(
I'm out of ideas... I've already googled it everywhere and i couldn't
find the solution.
More information about the Tutor
mailing list