I've got an issue with translations not working on Django 1.6. I've added this to my settings.py:
LANGUAGE_CODE = 'en-us'
ugettext = lambda s: s
LANGUAGES = (
('en', ugettext('English')),
('de', ugettext('German')),
)
Also added middlewares:
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',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
as well as to my *.py files whenever I'm using a string which shall be l10nd:
from django.utils.translation import ugettext_lazy as _
My templates start with:
{% extends "base.html" %}
{% load i18n %}
and inside the template I used the trans
placeholder. E.g.
<h1>{% trans "Register a tank" %}</h1>
I have provided translations in locale/de/LC_MESSAGES/django.po:
msgid "Register a tank"
msgstr "Einen neuen Tank anmelden"
My browser is set to request German content first: Browser settings
What did I miss?
P.S. The project I'm currently fuzzy around is hosted on GitHub: https://github.com/frlan/blankspot
See Question&Answers more detail:os