A typical language_chooser from multilingual Django-CMS framework, displays languages like this:
<a href="{% page_language_url language.0 %}">{% trans language.1 %}</a>
English German Dutch
How should this snippet be changed, to translate each language into it's own native form, so that the output would be
English Deutsch Nederlands
Making it easier for people to find on the page?
Django is a web framework which can sometimes be used to make a CMS, but it is not, by itself, a full CMS.
Django offers multiple language support out-of-the-box. In fact, Django is translated into more than 100 languages. This tutorial looks at how to add multiple language support to your Django project.
While @mongoose_za's answer is thorough and useful, it answers a different question and not the one posed.
The real answer is simply to change your list of languages in settings to include those native forms as such:
LANGUAGES = (
('de', u'Deutsch'),
('en', u'English'),
('nl', u'Nederlands'),
('es', u'Español'),
('fr', u'français'),
('jp', u'日本語'),
)
I've added a couple to make it more obvious what we're doing.
Since you wish to always display the languages in their native way, there's no need to translate them, thus, there's no need for the ugettext() wrappers. You want to make sure that the first line in your settings file is:
# -*- coding: utf-8 -*-
To ensure everything is interpreted correctly by Python.
An excellent source for this exercise is here: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With