From 2ca3af423ae1aea12fbd35afef61883a8762c4e5 Mon Sep 17 00:00:00 2001 From: papoteur-mga Date: Sat, 13 Dec 2014 09:19:42 +0100 Subject: Added Interntionalization Added French translation --- CHANGELOG | 3 + mageiaSync/mageiaSync.pro | 22 ++ mageiaSync/mageiaSyncDBprefs.py | 4 +- mageiaSync/mageiaSyncExt.py | 22 +- mageiaSync/mageiaSync_en.ts | 441 +++++++++++++++++++++++++++++++++ mageiaSync/mageiaSync_fr.ts | 522 ++++++++++++++++++++++++++++++++++++++++ mageiaSync/mageiasync.py | 64 ++--- 7 files changed, 1037 insertions(+), 41 deletions(-) create mode 100644 mageiaSync/mageiaSync.pro create mode 100644 mageiaSync/mageiaSync_en.ts create mode 100644 mageiaSync/mageiaSync_fr.ts diff --git a/CHANGELOG b/CHANGELOG index d243bfb..7750fd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ The modifications are: + - internationalization. + + mageiasync 0.1.2 ------------ - added shortcuts. diff --git a/mageiaSync/mageiaSync.pro b/mageiaSync/mageiaSync.pro new file mode 100644 index 0000000..263efb3 --- /dev/null +++ b/mageiaSync/mageiaSync.pro @@ -0,0 +1,22 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-12-07T13:03:24 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = mageiaSync +TEMPLATE = app + + +SOURCES +=mageiasync.py mageiaSyncExt.py + + +HEADERS += + +FORMS += mageiaSyncUI.ui mageiaSyncDBprefs.ui mageiaSyncDBprefs0.ui mageiaSyncDBrename.ui mageiaSyncDBupdate.ui +TRANSLATIONS += mageiaSync_en.ts +TRANSLATIONS += mageiaSync_fr.ts diff --git a/mageiaSync/mageiaSyncDBprefs.py b/mageiaSync/mageiaSyncDBprefs.py index d96c74c..1d78be6 100644 --- a/mageiaSync/mageiaSyncDBprefs.py +++ b/mageiaSync/mageiaSyncDBprefs.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'mageiaSyncDBprefs.ui' +# Form implementation generated from reading ui file '/documents/mageiasync/mageiaSync/mageiaSyncDBprefs.ui' # -# Created: Sat Sep 20 19:26:02 2014 +# Created: Sun Dec 7 13:24:26 2014 # by: PyQt5 UI code generator 5.1.1 # # WARNING! All changes made in this file will be lost! diff --git a/mageiaSync/mageiaSyncExt.py b/mageiaSync/mageiaSyncExt.py index ebd224f..3071199 100644 --- a/mageiaSync/mageiaSyncExt.py +++ b/mageiaSync/mageiaSyncExt.py @@ -121,16 +121,16 @@ class syncThread(QThread): self.stopped=True try: self.process.terminate() - self.lvM.emit("Process rsync stopped") + self.lvM.emit(self.tr("Process rsync stopped")) self.list=[] except: - self.lvM.emit("Process rsync already stopped") + self.lvM.emit(self.tr("Process rsync already stopped")) # Init progressbar and speed counter self.endSignal.emit(0) def run(self): if len(self.list)==0: - self.lvM.emit("No entry selected") + self.lvM.emit(self.tr("No entry selected")) for iso in self.list: errorOccured=True self.lvM.emit("Starting rsync with "+iso['nameWithPath']) @@ -186,7 +186,7 @@ class syncThread(QThread): self.process.poll() if self.process.returncode != None: break - self.lvM.emit("Ending with "+iso['nameWithPath']) + self.lvM.emit(self.tr("Ending with ")+iso['nameWithPath']) if self.stopped: break else: @@ -214,7 +214,7 @@ def rename(directory,oldRelease,newRelease): item=process.stderr.readline().rstrip() return 'Error ', item break - return "Success in renaming" + return tr("Success in renaming") class findIsos(QThread): endSignal=pyqtSignal(int) @@ -261,16 +261,16 @@ class findIsos(QThread): else: process = Popen(commande, shell=False, stdout=PIPE, stderr=PIPE) except OSError as e: - self.lvM.emit("Command rsync not found: "+str(e)) + self.lvM.emit(self.tr("Command rsync not found: ")+str(e)) self.endSignal.emit(1) return except ValueError as e: - self.lvM.emit("Error in rsync parameters: "+str(e)) + self.lvM.emit(self.tr("Error in rsync parameters: ")+str(e)) self.endSignal.emit(2) return except Exception as e: # Unknown error in rsync - self.lvM.emit("Error in rsync: "+str(e)) + self.lvM.emit(self.tr("Error in rsync: ")+str(e)) self.endSignal.emit(3) return process.poll() @@ -298,14 +298,14 @@ def findRelease(releasePath, password): # List the remote list of relea process = Popen(commande, shell=False, stdout=PIPE, stderr=PIPE) except OSError as e: code=1 - return code, "Command rsync not found: "+str(e) + return code,self.tr("Command rsync not found: ")+str(e) except ValueError as e: code=2 - return code,"Error in rsync parameters: "+str(e) + return code,self.tr("Error in rsync parameters: ")+str(e) except Exception as e: # Unknown error in rsync code=3 - return code, "Error in rsync: "+str(e) + return code,self.tr("Error in rsync: ")+str(e) process.poll() while True : item=process.stdout.readline().rstrip().decode('unicode_escape') diff --git a/mageiaSync/mageiaSync_en.ts b/mageiaSync/mageiaSync_en.ts new file mode 100644 index 0000000..661a27d --- /dev/null +++ b/mageiaSync/mageiaSync_en.ts @@ -0,0 +1,441 @@ + + + + @default + + + Success in renaming + + + + + Dialog + + + Dialog + + + + + Loading images list from repository... + + + + + IsosViewer + + + Directory + + + + + Name + + + + + Size + + + + + Date + + + + + bytes + + + + + Checking + + + + + OK + + + + + Failed + + + + + Command rsync not found + + + + + Error in rsync parameters + + + + + Unknown error in rsync + + + + + the user must set values or default values + + + + + Local directory: + + + + + Remote directory: + + + + + Select a directory + + + + + Unselect &All + + + + + Select &All + + + + + Source: + + + + + LogWindow + + + Loading images list from repository. + + + + + dbWarning + + + Loading images list from repository. + + + + + Loading... + + + + + findIsos + + + Error in rsync parameters: + + + + + Command rsync not found: + + + + + Error in rsync: + + + + + mainWindow + + + MageiaSync + + + + + Remote directory + + + + + Select &All + + + + + Local directory: + + + + + 0 bytes + + + + + kB/s + + + + + Remaining: + + + + + H:mm:ss + + + + + &Do sync + + + + + &Stop + + + + + &Quit + + + + + Report + + + + + &File + + + + + S&ync + + + + + &Update list + + + + + &Preferences + + + + + &Rename archives + + + + + &Check + + + + + Check selected images + + + + + prefsDialog + + + Preferences + + + + + Give the release name like "mageia5-alpha2" + + + + + Release: + + + + + User name to acces the repository. Only for testing repository. + + + + + User: + + + + + Associated with user, if needed + + + + + Password: + + + + + Source repository. Keep void to use the testing repo. + + + + + Source: + + + + + The local directory where you store ISOs. Will sync your existent ISOs already present. + + + + + Destination: + + + + + PushButton + + + + + Set to zero if you don't want apply limit. + + + + + Bandwith limit (kB/s): + + + + + Define parameters which are stored and used for rsync + + + + + prefsDialog0 + + + Preferences + + + + + Define parameters which are stored and used for rsync + + + + + User name to acces the repository. Only for testing repository. + + + + + User: + + + + + Associated with user, if needed + + + + + Password: + + + + + Give a value if you want to use testing repository + + + + + Source repository. Keep void to use the testing repo. + + + + + Source: + + + + + Give a mirror adress with public access + + + + + renameDialog + + + Rename release + + + + + Old release + + + + + New release + + + + + This action renames the directories and names from a former version to a new one. + + + + + Base directory + + + + + PushButton + + + + + syncThread + + + Process rsync stopped + + + + + Process rsync already stopped + + + + + No entry selected + + + + + Ending with + + + + diff --git a/mageiaSync/mageiaSync_fr.ts b/mageiaSync/mageiaSync_fr.ts new file mode 100644 index 0000000..5ca68e9 --- /dev/null +++ b/mageiaSync/mageiaSync_fr.ts @@ -0,0 +1,522 @@ + + + + + @default + + + Command rsync not found + Commande rsync non disponible + + + + Error in rsync parameters + Erreur dans les paramètres de rsync + + + + Unknown error in rsync + Erreur inconnue avec rsync + + + + the user must set values or default values + l'utilisateur doit spécifier des valeurs + + + + Local directory: + Répertoire local : + + + + Remote directory: + Dépôt distant : + + + + Select a directory + Sélectionner un répertoire + + + + Unselect &All + Désélectionner &Tout + + + + Select &All + Sélectionner &Tout + + + + Process rsync stopped + Processus rsync arrêté + + + + Process rsync already stopped + Processus rsync déjà arrêté + + + + No entry selected + pas d'entrée sélectionnée + + + + Ending with + Fin de + + + + Error in rsync parameters: + Erreur dans les paramètres de rsync : + + + + Command rsync not found: + Commande rsync non disponible : + + + + Error in rsync: + Erreur avec rsync : + + + + Success in renaming + Renommage effectué avec succès + + + + Dialog + + + Dialog + Dialogue + + + + Loading images list from repository... + Chargement de la liste des images depuis le dépôt... + + + + IsosViewer + + + Directory + Répertoire + + + + Name + Nom + + + + Size + Taille + + + + Date + Date + + + + bytes + octects + + + + Checking + Vérification + + + + OK + + + + + Failed + Échec + + + + Command rsync not found + Commande rsync non disponible + + + + Error in rsync parameters + Erreur dans les paramètres de rsync + + + + Unknown error in rsync + Erreur inconnue avec rsync + + + + the user must set values or default values + l'utilisateur doit spécifier des valeurs + + + + Local directory: + Répertoire local : + + + + Remote directory: + Dépôt distant : + + + + Select a directory + Sélectionner un répertoire + + + + Unselect &All + Désélectionner &Tout + + + + Select &All + Sélectionner &Tout + + + + Source: + Source : + + + + LogWindow + + + Loading images list from repository. + Chargement des images depuis le dépôt. + + + + dbWarning + + + Loading images list from repository. + Chargement des images depuis le dépôt. + + + + Loading... + Chargement... + + + + findIsos + + + Error in rsync parameters: + Erreur dans les paramètres de rsync : + + + + Command rsync not found: + Commande rsync non disponible : + + + + Error in rsync: + Erreur avec rsync : + + + + mainWindow + + + MageiaSync + MageiaSync + + + + Remote directory + Dépôt distant + + + + Select &All + Sélectionner &Tout + + + + Local directory: + Répertoire local : + + + + 0 bytes + 0 octets + + + + kB/s + kB/s + + + + Remaining: + Restant : + + + + H:mm:ss + H:mm:ss + + + + &Do sync + S&ynchronise + + + + &Stop + &Stop + + + + &Quit + &Quitter + + + + Report + Sorties + + + + &File + &Fichier + + + + S&ync + S&ynchronise + + + + &Update list + Act&ualiser la liste + + + + &Preferences + &Préférences + + + + &Rename archives + &Renommer les fichiers locaux + + + + &Check + &Vérification + + + + Check selected images + Vérifier les images sélectionnées + + + + prefsDialog + + + Preferences + Préférences + + + + Give the release name like "mageia5-alpha2" + Donner le nom de version, tel que "mageia5-alpha2" + + + + Release: + Version : + + + + User name to acces the repository. Only for testing repository. + Nom d'utilisateur pour accéder au répertoire distant. Uniquement pour le dépôt de test. + + + + User: + Utilisateur : + + + + Associated with user, if needed + Associé à l'utilisateur, si nécessaire + + + + Password: + Mot de passe : + + + + Source repository. Keep void to use the testing repo. + Dépôt source : laisser vide pour utiliser le dépôt de test. + + + + Source: + Source : + + + + The local directory where you store ISOs. Will sync your existent ISOs already present. + Le répertoire local où stocker les images. Les images existantes seront synchronisées si elles sont déjà là. + + + + Destination: + Destination : + + + + PushButton + + + + + Set to zero if you don't want apply limit. + Mettre à zéro pour ne pas appliquer de limitation. + + + + Bandwith limit (kB/s): + Limite de bande passante utilisée (kB/s) : + + + + Define parameters which are stored and used for rsync + Définir les paramètres qui sont stockés et utilisés par rsync + + + + prefsDialog0 + + + Preferences + Préférences + + + + Define parameters which are stored and used for rsync + Définir les paramètres qui sont stockés et utilisés par rsync + + + + User name to acces the repository. Only for testing repository. + Nom d'utilisateur pour accéder au dépôt distant. Uniquement pour le dépôt de test. + + + + User: + Utilisateur : + + + + Associated with user, if needed + Associé à l'utilisateur, si nécessaire + + + + Password: + Mot de passe : + + + + Give a value if you want to use testing repository + Donner une valeur pour utiliser le dépôt de test + + + + Source repository. Keep void to use the testing repo. + Dépôt source : laisser vide pour utiliser la source de test. + + + + Source: + Source : + + + + Give a mirror adress with public access + Donner une adresse de miroir avec un accès public + + + + renameDialog + + + Rename release + Renommer la version + + + + Old release + Ancienne version + + + + New release + Nouvelle version + + + + This action renames the directories and names from a former version to a new one. + Cette action renomme les répertoires et les noms d'une version précédente pour une nouvelle. + + + + Base directory + Répertoire de base + + + + PushButton + + + + + syncThread + + + Process rsync stopped + Processus rsync arrêté + + + + Process rsync already stopped + Processus rsync déjà arrêté + + + + No entry selected + Pas d'entrée sélectionnée + + + + Ending with + Fin de + + + diff --git a/mageiaSync/mageiasync.py b/mageiaSync/mageiasync.py index 07ea7a5..cc61183 100644 --- a/mageiaSync/mageiasync.py +++ b/mageiaSync/mageiasync.py @@ -1,8 +1,9 @@ -#!/usr/bin/python3 +#!/usr/bin/python from PyQt5.QtWidgets import ( QProgressDialog, QMainWindow, QDialog, QFileDialog, QApplication) from PyQt5.QtGui import ( QStandardItemModel,QStandardItem, ) +from PyQt5.QtCore import ( QLibraryInfo, ) from PyQt5 import QtCore # , Qt, QThread, QObject, pyqtSignal) import sys import mageiaSyncUI @@ -41,7 +42,7 @@ class LogWindow(QProgressDialog): super(LogWindow, self).__init__(parent) self.setWindowModality(QtCore.Qt.WindowModal) self.setWindowTitle('Loading...') - self.setLabelText('Loading images list from repository.') + self.setLabelText(self.tr('Loading images list from repository.')) self.setMinimum(0) self.setMaximum(0) self.setAutoReset(False) @@ -57,8 +58,8 @@ class dbWarning(QProgressDialog): def __init__(self, parent=None): super(dbWarning, self).__init__(parent) self.setWindowModality(QtCore.Qt.WindowModal) - self.setWindowTitle('Loading...') - self.setLabelText('Loading images list from repository.') + self.setWindowTitle(self.tr('Loading...')) + self.setLabelText(self.tr('Loading images list from repository.')) self.setMinimum(0) self.setMaximum(0) self.setAutoReset(False) @@ -93,7 +94,7 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): # Model for list view in a table self.model = QStandardItemModel(0, 6, self) - headers=["Directory","Name","Size","Date","SHA1","MD5"] + headers=[self.tr("Directory"),self.tr("Name"),self.tr("Size"),self.tr("Date"),"SHA1","MD5"] i=0 for label in headers: self.model.setHeaderData(i, QtCore.Qt.Horizontal,label ) @@ -144,7 +145,7 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): def setSize(self, size): # Update the size field - self.Lsize.setText(size+" bytes") + self.Lsize.setText(size+self.tr(" bytes")) def setRemain(self,remainTime): content=QtCore.QTime.fromString(remainTime,"h:mm:ss") @@ -186,32 +187,32 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): # the hundred contains index of the value to check, the minor value contains the row col=(int)(isoIndex/100) row=isoIndex-col*100 - self.model.setData(self.model.index(row, col, QtCore.QModelIndex()), "Checking") + self.model.setData(self.model.index(row, col, QtCore.QModelIndex()), self.tr("Checking")) def md5Check(self,check): if check>=128: - val="OK" + val=self.tr("OK") row=check-128 else: - val="Failed" + val=self.tr("Failed") row=check self.model.setData(self.model.index(row, 5, QtCore.QModelIndex()), val) def sha1Check(self,check): if check>=128: - val="OK" + val=self.tr("OK") row=check-128 else: - val="Failed" + val=self.tr("Failed") row=check self.model.setData(self.model.index(row, 4, QtCore.QModelIndex()), val) def dateCheck(self,check): if check>=128: - val="OK" + val=self.tr("OK") row=check-128 else: - val="Failed" + val=self.tr("Failed") row=check self.model.setData(self.model.index(row, 3, QtCore.QModelIndex()), val) @@ -222,11 +223,11 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): def syncEnd(self, rc): if rc==1: - self.lvMessage("Command rsync not found") + self.lvMessage(self.tr("Command rsync not found")) elif rc==2: - self.lvMessage("Error in rsync parameters") + self.lvMessage(self.tr("Error in rsync parameters")) elif rc==3: - self.lvMessage("Unknown error in rsync") + self.lvMessage(self.tr("Unknown error in rsync")) self.IprogressBar.setEnabled(False) self.syncGo.setEnabled(True) self.listIsos.setEnabled(True) @@ -291,7 +292,7 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): else: pass # answer=QDialogButtonBox(QDialogButtonBox.Ok) - print("the user must set values or default values") + print(self.tr("the user must set values or default values")) self.pd.close() else: self.release=params.value("release", type="QString") @@ -300,13 +301,13 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): self.password=params.value("password", type="QString") self.destination=params.value("destination", type="QString") self.bwl=params.value("bwl",type=int) - self.localDirLabel.setText("Local directory: "+self.destination) + self.localDirLabel.setText(self.tr("Local directory: ")+self.destination) if self.location !="": - self.remoteDirLabel.setText("Remote directory: "+self.location) + self.remoteDirLabel.setText(self.tr("Remote directory: ")+self.location) def selectDestination(self): # dialog box to select the destination (local directory) - directory = QFileDialog.getExistingDirectory(self, 'Select a directory','~/') + directory = QFileDialog.getExistingDirectory(self, self.tr('Select a directory'),'~/') isosSync.destination = directory self.pd.selectDest.setText(isosSync.destination) @@ -316,11 +317,11 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): if self.selectAllState : for i in range(self.listIsos.count()): self.listIsos.item(i).setSelected(True) - self.selectAll.setText("Unselect &All") + self.selectAll.setText(self.tr("Unselect &All")) else: for i in range(self.listIsos.count()): self.listIsos.item(i).setSelected(False) - self.selectAll.setText("Select &All") + self.selectAll.setText(self.tr("Select &All")) self.selectAllState=not self.selectAllState def connectActions(self): @@ -344,13 +345,13 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): # print self.nameWithPath else: self.nameWithPath=self.location+'/' - self.lvMessage("Source: "+self.nameWithPath) + self.lvMessage(self.tr("Source: ")+self.nameWithPath) self.fillList = mageiaSyncExt.findIsos() self.fillList.setup(self.nameWithPath, self.password,self.destination) self.fillList.endSignal.connect(self.closeFill) self.fillList.start() # Reset the button - self.selectAll.setText("Select &All") + self.selectAll.setText(self.tr("Select &All")) self.selectAllState=True def lvMessage( self,message): @@ -359,7 +360,7 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): def renameDir(self): # Choose the directory where isos are stored - directory = QFileDialog.getExistingDirectory(self, 'Select a directory',self.destination) + directory = QFileDialog.getExistingDirectory(self, self.tr('Select a directory'),self.destination) self.rd.chooseDir.setText(directory) def rename(self): @@ -436,11 +437,11 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): for iso in list: self.add(iso) elif code==1: - self.lvMessage("Command rsync not found") + self.lvMessage(self.tr("Command rsync not found")) elif code==2: - self.lvMessage("Error in rsync parameters") + self.lvMessage(self.tr("Error in rsync parameters")) elif code==3: - self.lvMessage("Unknown error in rsync") + self.lvMessage(self.tr("Unknown error in rsync")) list=self.fillList.getList() list=self.fillList.getLocal() @@ -472,6 +473,13 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): if __name__=='__main__': app = QApplication(sys.argv) + locale = QtCore.QLocale.system().name() + qtTranslator = QtCore.QTranslator() + if qtTranslator.load("qt_" + locale,QLibraryInfo.location(QLibraryInfo.TranslationsPath)): + app.installTranslator(qtTranslator) + appTranslator = QtCore.QTranslator() + if appTranslator.load("mageiaSync_" + locale,QLibraryInfo.location(QLibraryInfo.TranslationsPath)): + app.installTranslator(appTranslator) isosSync = IsosViewer() isosSync.main() sys.exit(app.exec_()) -- cgit v1.2.1