fa.bianp.net

django, change language settings dynamically

Category: General, Tecnologí­a

After some failed attempts, I just found how to change the language settings dynamically in django, and I thought it could be useful to someone. Just use function activate() from django.utils.translation. For example: [cc lang="python"] from django.utils.translation import activate activate('es-ES') [/cc] will change global language settings to 'es-ES' (Spain spanish). I use it because I have two forms and I want that errors appear in different languages, but I do not want to get into gettext