The EnSight core includes an instance of the CEItranslate object. It is accessed as:
When the ensight.core module loads and scans the directories for extensions, it also scans for any *.qm files and automatically registers them with ensight.core.tr. Thus, if you have internationalized an extension GUI (or any other Qt gui), simply place the translation files in the extensions directory and they will be loaded. When the QApplication instance is created, ensight.core.tr.changelang() is called. If the user has set CEI_LANG (or the host system has a language set), those translation files are automatically loaded.
In Python code, you can trap and handle dynamic language changes by including the following method to your top level widget:
# i18n bits: handle dynamic language changes
def changeEvent(self, event):
if (event.type() == QtCore.QEvent.LanguageChange):
Note that you may need to change ‘QMainWindow’ to the appropriate classname. The ‘self.retranslateUi()’ call should be replaced with whatever function regenerates the GUI text contents on your system (it may be more than one call to autogenerated retranslateUi() methods.