Beispiel #1
0
 def set_language(self, language):
     try:
         language = getattr(QtCore.QLocale, language, 'system')
         if isinstance(language, int):
             locale = QtCore.QLocale(language).name()
         elif callable(language):
             locale = language().name()
         else:
             locale = QtCore.QLocale.system().name()
         root_dir = os.path.dirname(os.path.dirname(__file__))
         path = os.path.join(root_dir, "res", "translations", locale)
         if self.translator.load(path):
             log.warning("Setting locale: %s" % locale)
             self.application._qapp.installTranslator(self.translator)
         else:
             log.warning("Translations not found at %s" % path)
     except Exception as e:
         log.exception(e)