I’m currently making a site where i want to implement multi-language version. which actually i don’t need but i want to do it just in case.
So will using django translation mechanism reduce performance and for how much?
Especially i want to hear people how have tested performance of django translation on real servers.
thanks in advance.
Can’t talk from experience about performance on real servers, but here are a few hints:
Django loads the gettext translations for a language into memory as soon as the language is activated (e.g. manually with
django.utils.translation.activate("de")). After the MO file is loaded, all further lookups are purely CPU-bound (memory lookup), so the performance hit shouldn’t matter at all.If I understand your question correctly, you only want to place translatable strings into the site so that you could translate them when necessary. In that case, just use
ugettext,{% trans %}etc. like you would do for a fully-translated site, but setUSE_I18N = False. That way, Django replaces its gettext functionality with dummy functions that will just return the original string. The overhead will be close to zero. If you want to add a second language, just activate i18n and don’t forget to compile the translations to MO files.