When you start translating your app things become very interesting and it really challenges the way you build you applications.
in your settings.py file you add all of the different languages
LANGUAGES = (
('en', gettext('English')),
('sv', gettext('Swedish')),
('no', gettext('Norwegian')),
)
no I know you can use get_current_language as LANGUAGE_CODE to access the first bit ie, en
is there a way in my template that I can access the display text ie, English ?
If you have
LANGUAGE_CODEyou can uselanguage_namefilter:(and many other possibilities: django template translation-specific variables)
In django < v1.3:
You can access available languages list via:
To show this ist:
As you can see language name is
lang.1(second member of the inner tuple)If you want the name of a language that you have it’s code, either put that in the context before passing it to the template or in the loop above add a comparaison condition to get the name.