I'm trying to activate different languages for my project. English and spanish right now.
I'll describe all steps i follow:
FIrst of all, i place myself in the directory i want to translate. Or better said, where all {% trans %} tags are:
$ cd media/templates/landing/
$ mkdir locale
$ django-admin.py makemessages --locale=en
Last command creates the directory/file /locale/en/LC_MESSAGES/django.po
I open django.po and i proceed to complete all msgstr fields in english language. msgid label is in spanish. I respect the tips about long messages case. After fill in this file, i make:
$ django-admin.py compilemessages
This process django.po and creates django.mo.
So i modify settings.py. Important lines:
TEMPLATE_CONTEXT_PROCESSORS = (
'ism.context_processor.user_vars',
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pipeline.middleware.MinifyHTMLMiddleware',
}
TIME_ZONE = 'Atlantic/Canary'
LANGUAGE_CODE = 'es'
USE_I18N = True
_ = lambda s: s
LANGUAGES = (
('es', _('Espanol')),
('en', _('English')),
)
USE_L10N = True
USE_TZ = True
Finally, i add this line to URLS.py:
(r'^i18n/', include('django.conf.urls.i18n')),
I restart my development server, i configure my Firefox browser to choose English first as primary language and it does not work. All texts still showing in spanish instead english.
I make sure Firefox is configured in english because in Django view function (which render the .html) i make a print with request.LANGUAGE_CODE, which prints "en".
What am I making wrong?