From Django Documentation:
If you define a custom
LANGUAGES
setting, it's OK to mark the languages as translation strings (as in the default value displayed above) -- but use a "dummy"gettext()
function, not the one indjango.utils.translation
. You should never importdjango.utils.translation
from within your settings file, because that module in itself depends on the settings, and that would cause a circular import. The solution is to use a "dummy"gettext()
function. Here's a sample settings file:
gettext = lambda s: s LANGUAGES = (
('de', gettext('German')),
('en', gettext('English')),
)
With this arrangement,
django-admin.py makemessages
will still find and mark these strings for translation, but the translation won't happen at runtime -- so you'll have to remember to wrap the languages in the realgettext()
in any code that usesLANGUAGES
at runtime.
What does it exactly mean to wrap languages in real gettext()
? How it should be called in the code?