From 518b1441e87a3c10a32798d19a001a19c3b576d4 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Tue, 7 Apr 2020 15:42:51 +0200 Subject: [PATCH] inizio lavoro per traduzione interfacce e messaggi di debug cosa lunghissima --- .../resources/translations/guimain.ts | 52 +++++++++++++++++++ bananaSPLIT/conf/defaults.json | 3 +- bananaSPLIT/guimain.py | 32 ++++++------ 3 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 bananaSPLIT/UserInterface/resources/translations/guimain.ts diff --git a/bananaSPLIT/UserInterface/resources/translations/guimain.ts b/bananaSPLIT/UserInterface/resources/translations/guimain.ts new file mode 100644 index 0000000..09800f6 --- /dev/null +++ b/bananaSPLIT/UserInterface/resources/translations/guimain.ts @@ -0,0 +1,52 @@ + + + + + @default + + + Impostazioni Titolo + + + + + Selezione Output + + + + + MainWindow: Configurazione non accettata + + + + + Prossima Tab + + + + + Tab Precedente + + + + + Apri Carica Preset + + + + + Carica Preset + + + + + Riempio tutte le tab + + + + + Apri Salva Preset + + + + diff --git a/bananaSPLIT/conf/defaults.json b/bananaSPLIT/conf/defaults.json index 5dc8e1e..c58c620 100644 --- a/bananaSPLIT/conf/defaults.json +++ b/bananaSPLIT/conf/defaults.json @@ -1,5 +1,5 @@ { - "version": "v1.3", + "version": "v1.4", "paths": { "lastUsed": "defaults.json", "configurationPath": "./conf/", @@ -36,6 +36,7 @@ } }, "settings": { + "uiLang": "it", "winW": 800, "winH": 700, "encoding": "windows-1252", diff --git a/bananaSPLIT/guimain.py b/bananaSPLIT/guimain.py index 33bbb97..f473a59 100644 --- a/bananaSPLIT/guimain.py +++ b/bananaSPLIT/guimain.py @@ -38,8 +38,8 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow): #popola le tab con le finestre giuste - self.ui.wgt_main.addTab(self.titolo, "Impostazioni Titolo") - self.ui.wgt_main.addTab(self.selezout, "Selezione Output") + self.ui.wgt_main.addTab(self.titolo, tr("Impostazioni Titolo")) + self.ui.wgt_main.addTab(self.selezout, tr("Selezione Output")) # connetti bottoni avanti self.ui.btn_avanti.clicked.connect(self.nextTab) @@ -84,7 +84,7 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow): self.ui.rad_fileOld.setChecked(not self.conf.getParam('docStruct', 'fileVersNew')) self.fillFileList() except: - self.log.critical("MainWindow: Configurazione non accettata") + self.log.critical(tr("MainWindow: Configurazione non accettata")) def fillAllInterfaces(self): self.fillInterface() @@ -104,32 +104,31 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow): def nextTab(self): self.ui.wgt_main.setCurrentIndex(self.ui.wgt_main.currentIndex()+1) - self.logger.debug("Prossima Tab") + self.logger.debug(tr("Prossima Tab")) pass def prevTab(self): self.ui.wgt_main.setCurrentIndex(self.ui.wgt_main.currentIndex()-1) - self.logger.debug("Tab Precedente") + self.logger.debug(tr("Tab Precedente")) pass def openLoadPreset(self): - self.logger.debug("Apri Carica Preset") - lf = PyQt5.QtWidgets.QFileDialog(self,"Carica Preset",self.conf.getParam('paths', 'configurationPath')) + self.logger.debug(tr("Apri Carica Preset")) + lf = PyQt5.QtWidgets.QFileDialog(self,tr("Carica Preset"),self.conf.getParam('paths', 'configurationPath')) lf.setAcceptMode(PyQt5.QtWidgets.QFileDialog.AcceptOpen) lf.setFileMode(PyQt5.QtWidgets.QFileDialog.ExistingFile) lf.setNameFilter("bananaCONF (*.json)") if lf.exec(): cf = str(lf.selectedFiles()[0].split('/')[-1]) - self.logger.info("Apro la configurazione: {}".format(cf)) + self.logger.info(tr(f"Apro la configurazione: {cf}")) self.conf.open() self.conf.use(cf) - self.logger.debug("Riempio tutte le tab") + self.logger.debug(tr("Riempio tutte le tab")) self.fillAllInterfaces() pass def openSavePreset(self): - self.logger.debug("Apri Salva Preset") - self.logger.debug("Forzo applica a tutte le tab") + self.logger.debug(tr("Apri Salva Preset")) self.applicaTutto() sf = PyQt5.QtWidgets.QFileDialog(self,"Salva Preset",self.conf.getParam('paths', 'configurationPath')) sf.setAcceptMode(PyQt5.QtWidgets.QFileDialog.AcceptSave) @@ -144,7 +143,7 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow): self.conf.save(fName="defaults.json") self.conf.use(prev) ## - self.logger.debug("Scrivo la configurazione: {}".format(rv)) + self.logger.debug(tr(f"Scrivo la configurazione: {rv}")) self.conf.save(fName=rv) pass @@ -569,7 +568,6 @@ if __name__ == '__main__': app = PyQt5.QtWidgets.QApplication(sys.argv) sys.excepthook = except_hook - try: LOGGER = fancyLogger(filepath=r"./conf/loggerconf.json",fileLog=False) conf = bananaCONF(workdir=r"./conf", logger=LOGGER) @@ -577,9 +575,11 @@ if __name__ == '__main__': conf.use("defaults.json") conf.use(conf.getParam('paths', 'lastUsed')) - #t = QTranslator() - #t.load(":/translations/mainwindow.qm") - #app.installTranslator(t) + iflan = conf.getParam('settings','uiLang') + if iflan != 'it': + t = QTranslator() + t.load(f":/tr/translations/mainwindow_{iflan}.qm") + app.installTranslator(t) except Exception as e: print(e)