I need to implement internationalization in my project, so i want to use i18n for static content while i use the app django-modeltranslation for the models. I support the following languages:
en-us (default) nl-nl de-de fr-fr es-es
While i am dutch, django does not change to language to dutch. I do have a english windows but chrome is set up dutch to test the internationalization. This is not the only problem, only the model translates itself when the default language changes. When i set the default language to dutch, all models will show the dutch translation but the static content stays english.
Note: I did use compilemessages and restarted the server
Settings.py
USE_I18N = True
LANGUAGE_CODE = 'en-us'
gettext = lambda s: s
LANGUAGES = (
('en-us', gettext('English')),
('nl-nl', gettext('Dutch')),
('fr-fr', gettext('French')),
('de-de', gettext('German')),
('es-es', gettext('Spain')),
)
LOCALE_PATHS = ('/vagrant/locale', )
/vagrant/locale/en-us/LC_MESSAGES/django.po (shortened file to display error)
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-05-17 23:14+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Language: en-us\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: PyDiving/settings.py:170
msgid "English"
msgstr ""
#: PyDiving/settings.py:171
msgid "Dutch"
msgstr ""
#: PyDiving/settings.py:172
msgid "French"
msgstr ""
#: PyDiving/settings.py:173
msgid "German"
msgstr ""
#: PyDiving/settings.py:174
msgid "Spain"
msgstr ""
#: company/templates/company/company_detail.html:22
msgid "City"
msgstr ""
/vagrant/locale/nl-nl/LC_MESSAGES/django.po (only showing differences to shorten post)
"Language: nl-nl\n"
#: company/templates/company/company_detail.html:28
msgid "Postal Code"
msgstr "Postcode"
#: company/templates/company/company_detail.html:34
msgid "City"
msgstr "Stad"
Template company/templates/company/company_detail.html
{% load i18n %}
{{ company.text }} # this is the model translation, this will change when i change the default language
{% trans "City" %} # this always says "City"
Outcome when default language is en-us
EnglishCity
where 'English is the content of the model'
default language nl-nl
NederlandsCity