From e7c93602a16b947f67f507ad9663b4455644c0de Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Mon, 23 Sep 2024 14:30:56 +0200
Subject: [PATCH] trad: Add some message window traduction.

---
 src/View/MainWindow.py       | 22 +++++++++++++---------
 src/View/Tools/ASubWindow.py |  3 +++
 src/View/Translate.py        | 26 ++++++++++++++++++++++++++
 src/lang/fr.ts               | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 946eb54e..4f28cd8f 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -496,6 +496,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
         self.update()
 
     def close_model(self):
+        if not self.dialog_close(cancel=True):
+            return
+
         self._study = None
         self.update_enable_action()
         self.conf.set_close_correctly()
@@ -745,15 +748,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
     ##################
 
     def msg_select_reach(self):
-        self.message_box("Please select a reach",
-                         "Geometry edition need a reach selected "
-                         "into river network window to work on it")
+        self.message_box(
+            self._trad["mb_select_reach_title"],
+            self._trad["mb_select_reach_msg"]
+        )
 
     def dialog_reopen_study(self):
         dlg = QMessageBox(self)
 
-        dlg.setWindowTitle("Last open study")
-        dlg.setText("Do you want to open again the last open study?")
+        dlg.setWindowTitle(self._trad["mb_last_open_title"])
+        dlg.setText(self._trad["mb_last_open_msg"])
         opt = QMessageBox.Cancel | QMessageBox.Ok  # | QMessageBox.Open
 
         dlg.setStandardButtons(opt)
@@ -793,9 +797,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
     def dialog_close(self, cancel=True):
         dlg = QMessageBox(self)
 
-        dlg.setWindowTitle("Close PAMHYR without saving study")
-        dlg.setText("Do you want to save current study before PAMHYR close ?")
-        opt = QMessageBox.Save | QMessageBox.Ignore
+        dlg.setWindowTitle(self._trad["mb_close_title"])
+        dlg.setText(self._trad["mb_close_msg"])
+        opt = QMessageBox.Save | QMessageBox.Close
         if cancel:
             opt |= QMessageBox.Cancel
 
@@ -807,7 +811,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
         if res == QMessageBox.Save:
             self.save_study()
             return True
-        elif res == QMessageBox.Ignore:
+        elif res == QMessageBox.Close:
             return True
         elif res == QMessageBox.Cancel:
             return False
diff --git a/src/View/Tools/ASubWindow.py b/src/View/Tools/ASubWindow.py
index f483b7b0..01db62f4 100644
--- a/src/View/Tools/ASubWindow.py
+++ b/src/View/Tools/ASubWindow.py
@@ -149,6 +149,9 @@ class WindowToolKit(object):
         msg.setInformativeText(informative_text)
         msg.setWindowTitle(window_title)
 
+        msg.findChild(QLabel, "qt_msgbox_label")\
+           .setFixedWidth(384)
+
         msg.exec_()
 
 
diff --git a/src/View/Translate.py b/src/View/Translate.py
index 90d7b423..e41812e9 100644
--- a/src/View/Translate.py
+++ b/src/View/Translate.py
@@ -102,3 +102,29 @@ class MainTranslate(UnitTranslate):
         self._dict["active_window"] = _translate(
             "MainWindow", "Enable this window"
         )
+
+        # Message box
+        self._dict["mb_select_reach_title"] = _translate(
+            "MainWindow", "Please select a reach"
+        )
+        self._dict["mb_select_reach_msg"] = _translate(
+            "MainWindow",
+            "This edition window need a reach selected "
+            "into the river network to work on it"
+        )
+
+        self._dict["mb_last_open_title"] = _translate(
+            "MainWindow", "Last open study"
+        )
+        self._dict["mb_last_open_msg"] = _translate(
+            "MainWindow",
+            "Do you want to open again the last open study?"
+        )
+
+        self._dict["mb_close_title"] = _translate(
+            "MainWindow", "Close without saving study"
+        )
+        self._dict["mb_close_msg"] = _translate(
+            "MainWindow",
+            "Do you want to save current study before closing it?"
+        )
diff --git a/src/lang/fr.ts b/src/lang/fr.ts
index 4bd645dd..3597c8aa 100644
--- a/src/lang/fr.ts
+++ b/src/lang/fr.ts
@@ -2481,6 +2481,41 @@
         <source>Data</source>
         <translation>Données</translation>
     </message>
+    <message>
+        <location filename="../View/Translate.py" line="107"/>
+        <source>Please select a reach</source>
+        <translation>Veuillez sélectionner un bief</translation>
+    </message>
+    <message>
+        <location filename="../View/Translate.py" line="110"/>
+        <source>Geometry edition need a reach selected into the river network to work on it</source>
+        <translation type="obsolete">L&apos;édition de la géométrie nécessite un bief sélectionné dans le réseau fluvial pour pouvoir travailler dessus</translation>
+    </message>
+    <message>
+        <location filename="../View/Translate.py" line="116"/>
+        <source>Last open study</source>
+        <translation>Dernière étude ouverte</translation>
+    </message>
+    <message>
+        <location filename="../View/Translate.py" line="119"/>
+        <source>Do you want to open again the last open study?</source>
+        <translation>Voulez-vous rouvrir la dernière étude ?</translation>
+    </message>
+    <message>
+        <location filename="../View/Translate.py" line="110"/>
+        <source>This edition window need a reach selected into the river network to work on it</source>
+        <translation>Cette fenêtre d&apos;édition a besoin d&apos;un bief sélectionné dans le réseau pour travailler dessus</translation>
+    </message>
+    <message>
+        <location filename="../View/Translate.py" line="124"/>
+        <source>Close without saving study</source>
+        <translation>Fermer sans sauvegarder l&apos;étude</translation>
+    </message>
+    <message>
+        <location filename="../View/Translate.py" line="127"/>
+        <source>Do you want to save current study before closing it?</source>
+        <translation>Souhaitez-vous sauvegarder l&apos;étude en cours avant de la fermer ?</translation>
+    </message>
 </context>
 <context>
     <name>MainWindow_reach</name>
-- 
GitLab