The official django doc suggests writing the following in settings.py
ugettext = lambda s: s LANGUAGES = ( ('de', ugettext('German')), ('en', ugettext('English')), )
With this arrangement, django-admin.py makemessages will still find and mark these lines for translation, but the translation will not be executed at run time - so you will have to remember to wrap the languages ββin real ugettext () in any code that uses LANGUAGES at run time .
But, I donβt understand where to wrap the code with real translation tags?
eg. my code is in the template
<form id="locale_switcher" method="POST" action="{% url localeurl_change_locale %}"> <label><b>{% trans "Language" %}:</b></label> <select name="locale" onchange="$('#locale_switcher').submit()"> {% for lang in LANGUAGES %} <option value="{{ lang.0 }}" {% ifequal lang.0 LANGUAGE_CODE %}selected="selected"{% endifequal %}> {{ lang.1 }}</option> {% endfor %} </select> <noscript> <input type="submit" value="Set" /> </noscript> </form>
Proposed Solution: Using Settings. LANGUAGES with correctly translated names using gettext ()
Shows an empty selection box without any text in any language
source share