I am currently working on a Linux-native GUI for 7-zip and have already completed the menu and toolbar. In them are of course a lot of text snippets that I translate using gettext. It is possible to switch the language of gettext live (just call the .install() method of the wanted translation), but I am stuck on how to update the labels on all the buttons to reflect that change of language in the background, instead of just having new dialogs be in the newly-selected language until the program is restarted.
I hope what I want is possible with not-too-much effort. Otherwise I could also switch to PyQt's built-in translation mechanism, but I'd like to keep using gettext.
gettextdoesn't look like much fun, even for a pure Python project, and the problems are only going to multiply for a GUI application with an event-loop. Qt's i18n support is a fully integrated solution. It's probably not perfect, and PyQt's implementation isn't complete, but it's hard to see how a hand-rolled solution could be any better - for one thing, how willgettexthandle all the built-in strings supplied by Qt?retranslateUIslots. This could be done by connecting them to a custom signal emitted by a handler that watches for language-change events.setText()on them. From Qt's point of view, it just receives a string as the label, when you construct the icons. Alternatively, force a restart of the application after a language switch.