[gettext] How to change language at run-time

pozz pozzugno at gmail.com
Thu Jun 15 07:32:10 EDT 2017


I know I can load multiple gettext.translation:

   it = gettext.translation('test', localedir="locale", languages=["it"])
   es = gettext.translation('test', localedir="locale", languages=["es"])

and install one translation at run-time when I want at a later time 
(when the user selects a new language):

   it.install()
or
   es.install()


However the problem is that strings already translated are not 
translated again when a new translation is installed.  So they stay at 
the language selected during start-up and don't change after a new 
install().

One solution is to restart the application, but I think there's a better 
and more elegant solution.



More information about the Python-list mailing list