Exemple #1
0
def languageDescription(translation):

    translator = QTranslator()
    translator.load(translation)

    locale = QLocale(translator.language())
    return QCoreApplication.translate("main", "{0} ({1})").format(
        locale.languageToString(locale.language()),
        locale.nativeLanguageName())
Exemple #2
0
    def createLanguageMenu(self):
        langPath = self.own_path + "languages" + os.sep

        langDirectory = QDir(langPath)
        for language_file in langDirectory.entryList(['*.qm']):
            language_code = language_file.split('.')[0]
            language = QLocale.languageToString(QLocale(language_code).language())
            language_icon = QIcon(langPath + language_code + '.png')
            action = QAction(language_icon, language, self)
            action.setCheckable(True)
            action.setData(language_code)
            self.menuLanguage.addAction(action)
            self.langGroup.addAction(action)
Exemple #3
0
 def onLanguageChanged(self, action):
     language_code = action.data()
     if language_code != self.currentLanguage:
         JalSettings().setValue('Language',
                                JalDB().get_language_id(language_code))
         QMessageBox().information(
             self, g_tr('MainWindow', "Restart required"),
             g_tr('MainWindow', "Language was changed to ") +
             QLocale.languageToString(QLocale(language_code).language()) +
             "\n" + g_tr(
                 'MainWindow',
                 "You should restart application to apply changes\n"
                 "Application will be terminated now"), QMessageBox.Ok)
         self.close()
Exemple #4
0
 def onLanguageChanged(self, action):
     language_code = action.data()
     if language_code != self.currentLanguage:
         executeSQL(self.db,
                    "UPDATE settings "
                    "SET value=(SELECT id FROM languages WHERE language = :new_language) WHERE name ='Language'",
                    [(':new_language', language_code)])
         QMessageBox().information(self, g_tr('MainWindow', "Restart required"),
                                   g_tr('MainWindow', "Language was changed to ") +
                                   QLocale.languageToString(QLocale(language_code).language()) + "\n" +
                                   g_tr('MainWindow', "You should restart application to apply changes\n"
                                        "Application will be terminated now"),
                                   QMessageBox.Ok)
         self.close()