From d299576a9765d635e8325a6a634e30bb923e3968 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Mon, 27 Mar 2023 14:55:03 +0200 Subject: [PATCH] ui: Set up translate features. --- src/lang/constant_string.py | 83 +++++++++++++++++++++++++++++++++++++ src/lang/create_ts.sh | 16 +++++++ src/pamhyr.py | 8 +++- src/view/MainWindow.py | 1 + src/view/ui/MainWindow.ui | 77 +++++----------------------------- 5 files changed, 117 insertions(+), 68 deletions(-) create mode 100644 src/lang/constant_string.py create mode 100755 src/lang/create_ts.sh diff --git a/src/lang/constant_string.py b/src/lang/constant_string.py new file mode 100644 index 00000000..b599389a --- /dev/null +++ b/src/lang/constant_string.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- + +from PyQt5.QtCore import QCoreApplication + +_translate = QCoreApplication.translate + + +# -------------------- A -------------------- + + +# -------------------- B -------------------- + + +# -------------------- C -------------------- + + +# -------------------- D -------------------- + + +# -------------------- E -------------------- + + +# -------------------- F -------------------- + + +# -------------------- G -------------------- + + +# -------------------- H -------------------- + + +# -------------------- I -------------------- + + +# -------------------- J -------------------- + + +# -------------------- K -------------------- + + +# -------------------- L -------------------- + + +# -------------------- M -------------------- + + +# -------------------- N -------------------- + + +# -------------------- O -------------------- + + +# -------------------- P -------------------- + + +# -------------------- Q -------------------- + + +# -------------------- R -------------------- + + +# -------------------- S -------------------- + + +# -------------------- T -------------------- + + +# -------------------- U -------------------- + + +# -------------------- V -------------------- + + +# -------------------- W -------------------- + + +# -------------------- X -------------------- + + +# -------------------- Y -------------------- + + +# -------------------- Z -------------------- diff --git a/src/lang/create_ts.sh b/src/lang/create_ts.sh new file mode 100755 index 00000000..c617d22a --- /dev/null +++ b/src/lang/create_ts.sh @@ -0,0 +1,16 @@ +#! /bin/sh + +SOURCES=$(find ../ -name "*.py") +FROM=$(find ../ -name "*.ui") + +LANG="fr de" + +for l in $LANG +do + pylupdate5 $SOURCES $FROM -ts $l.ts +done + +for l in $LANG +do + lrelease $l.ts $l.qm +done diff --git a/src/pamhyr.py b/src/pamhyr.py index 53a99404..439872a8 100755 --- a/src/pamhyr.py +++ b/src/pamhyr.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import sys +import sys, os +from PyQt5.QtCore import QTranslator from PyQt5.QtWidgets import QApplication from config import Config @@ -12,6 +13,11 @@ from model.Study import Study def main(): conf = Config.load() app = QApplication(sys.argv) + + translator = QTranslator() + translator.load(os.path.dirname(__file__) + "/lang/fr.qm") + app.installTranslator(translator) + application = ApplicationWindow(conf=conf) application.show() sys.exit(app.exec_()) diff --git a/src/view/MainWindow.py b/src/view/MainWindow.py index 3f1337ed..24a70235 100644 --- a/src/view/MainWindow.py +++ b/src/view/MainWindow.py @@ -61,6 +61,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow): self.init_callback() self.default_style() + #self.ui.retranslateUi() def enable_actions(self, action:str, enable:bool): """Enable of disable an action componant diff --git a/src/view/ui/MainWindow.ui b/src/view/ui/MainWindow.ui index e9f8b691..8ccb78f6 100644 --- a/src/view/ui/MainWindow.ui +++ b/src/view/ui/MainWindow.ui @@ -615,63 +615,6 @@ - - - Ligne d'eau - - - - - Ligne d'eau finale - - - - - Ligne d'eau enveloppe - - - - - Vitesse(Pk) à t fixé - - - - - Vitesse(t) à Pk fixé - - - - - Charge hydraulique(Pk) à t fixé - - - - - Charge hydraulique(t) à Pk fixé - - - - 75 - true - - - - - - Voir l'animation (MAGE) - - - - - Autres résulats MAGE - - - - 75 - true - - - Map current reach @@ -758,7 +701,7 @@ Run solver - Lancer le solveur pour réaliser une simulation + Run solver on current study Ctrl+X @@ -791,7 +734,7 @@ Run external meshing tool - Lancer le mailleur externe sur la géométrie du bief courant + Run meshing tool on current reach geometry @@ -806,7 +749,7 @@ Display simulation listing - Aficher les listings de la simulation courante + Display current simulation listing @@ -818,7 +761,7 @@ River network - Open river network edition + Edit river network @@ -830,7 +773,7 @@ Geometry - Open geometry edition + Edit reach geometry @@ -861,7 +804,7 @@ Lateral contribution - Ouvrir l'éditeur des Apports Latéraux Distribués + Edit lateral contribution @@ -869,7 +812,7 @@ Spills - Ouvrir l'éditeur des Déversements Latéraux + Edit lateral spills @@ -877,7 +820,7 @@ Sections - Ouvrir l'éditeur des tronçons pour les frottements et Apports Latéraux + Edit section frictions and lateral contributions @@ -885,7 +828,7 @@ Frictions - Ouvrir l'éditeur des frottements au fond + Edit friction at the bottom @@ -893,7 +836,7 @@ Building - Ouvrir l'éditeur des ouvrages (seuils, vannes, etc.), singularités et pompes + Edit building (valve, ...), singularity and pump