Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-cms language_chooser in that language

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?

like image 823
qdot Avatar asked Jan 25 '12 05:01

qdot


People also ask

Is Django is a CMS?

Django is a web framework which can sometimes be used to make a CMS, but it is not, by itself, a full CMS.

Is Django multilingual?

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.


1 Answers

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

like image 88
mkoistinen Avatar answered Sep 27 '22 20:09

mkoistinen