From b1d0e6dc558d77839246e96420146bff400c53ee Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Mon, 12 Feb 2024 15:34:30 +0100
Subject: [PATCH] SL: Add windows title translate.

---
 src/View/SedimentLayers/Edit/Window.py        | 13 +++++-----
 src/View/SedimentLayers/Edit/translate.py     |  6 ++++-
 .../SedimentLayers/Reach/Profile/Window.py    | 25 ++++++++++++++++---
 .../SedimentLayers/Reach/Profile/translate.py | 20 +++++++++++++++
 src/View/SedimentLayers/Reach/SLDialog.py     |  4 +--
 src/View/SedimentLayers/Reach/Window.py       |  6 +++--
 src/View/SedimentLayers/Reach/translate.py    | 23 +++++++++++++++++
 src/View/SedimentLayers/Window.py             |  5 ++--
 src/View/SedimentLayers/translate.py          |  4 +++
 9 files changed, 89 insertions(+), 17 deletions(-)

diff --git a/src/View/SedimentLayers/Edit/Window.py b/src/View/SedimentLayers/Edit/Window.py
index 080eee3f..2c19c0e1 100644
--- a/src/View/SedimentLayers/Edit/Window.py
+++ b/src/View/SedimentLayers/Edit/Window.py
@@ -1,5 +1,5 @@
 # Window.py -- Pamhyr
-# Copyright (C) 2023  INRAE
+# Copyright (C) 2023-2024  INRAE
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -60,19 +60,20 @@ class EditSedimentLayersWindow(PamhyrWindow):
                  sl=None, parent=None):
         self._sl = sl
 
-        name = self._sl.name
-        if name == "":
-            name = _translate("SedimentLayers", "(no name)")
+        sl_name = self._sl.name
+        if sl_name == "":
+            sl_name = _translate("SedimentLayers", "(no name)")
 
+        trad = SedimentEditTranslate()
         name = (
-            self._pamhyr_name + " - " + study.name + " - " + name
+            trad[self._pamhyr_name] + " - " + study.name + " - " + sl_name
         )
 
         super(EditSedimentLayersWindow, self).__init__(
             title=name,
             study=study,
             config=config,
-            trad=SedimentEditTranslate(),
+            trad=trad,
             parent=parent
         )
 
diff --git a/src/View/SedimentLayers/Edit/translate.py b/src/View/SedimentLayers/Edit/translate.py
index 94ab91eb..31117fd7 100644
--- a/src/View/SedimentLayers/Edit/translate.py
+++ b/src/View/SedimentLayers/Edit/translate.py
@@ -11,7 +11,11 @@ class SedimentEditTranslate(SedimentTranslate):
     def __init__(self):
         super(SedimentEditTranslate, self).__init__()
 
-        self._dict["height"] = _translate("SedimentLayers", "Thickness (m)"),
+        self._dict["Edit Sediment Layers"] = _translate(
+            "SedimentLayers", "Edit Sediment Layers"
+        )
+
+        self._dict["height"] = _translate("SedimentLayers", "Thickness (m)")
 
         self._sub_dict["table_headers"] = {
             "name": _translate("SedimentLayers", "Name"),
diff --git a/src/View/SedimentLayers/Reach/Profile/Window.py b/src/View/SedimentLayers/Reach/Profile/Window.py
index 22ca8fcb..b7bdec22 100644
--- a/src/View/SedimentLayers/Reach/Profile/Window.py
+++ b/src/View/SedimentLayers/Reach/Profile/Window.py
@@ -1,3 +1,19 @@
+# Window.py -- Pamhyr
+# Copyright (C) 2024  INRAE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
 # -*- coding: utf-8 -*-
 
 import logging
@@ -49,13 +65,14 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
         self._profile = profile
         self._reach = profile.reach
 
-        name = self.compute_name(study)
+        trad = SedimentProfileTranslate()
+        name = self.compute_name(study, trad)
 
         super(ProfileSedimentLayersWindow, self).__init__(
             title=name,
             study=study,
             config=config,
-            trad=SedimentProfileTranslate(),
+            trad=trad,
             parent=parent
         )
 
@@ -65,7 +82,7 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
 
         self.ui.setWindowTitle(self._title)
 
-    def compute_name(self, study):
+    def compute_name(self, study, trad):
         rname = self._reach.name
         if rname == "":
             rname = _translate("SedimentLayers", "(no name)")
@@ -78,7 +95,7 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
                                            )
 
         return (
-            self._pamhyr_name + " - "
+            trad[self._pamhyr_name] + " - "
             + study.name + " - "
             + rname + " - " + pname
         )
diff --git a/src/View/SedimentLayers/Reach/Profile/translate.py b/src/View/SedimentLayers/Reach/Profile/translate.py
index 81e6623d..c811b188 100644
--- a/src/View/SedimentLayers/Reach/Profile/translate.py
+++ b/src/View/SedimentLayers/Reach/Profile/translate.py
@@ -1,3 +1,19 @@
+# translate.py -- Pamhyr
+# Copyright (C) 2024  INRAE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
 # -*- coding: utf-8 -*-
 
 from PyQt5.QtCore import QCoreApplication
@@ -11,6 +27,10 @@ class SedimentProfileTranslate(SedimentReachTranslate):
     def __init__(self):
         super(SedimentProfileTranslate, self).__init__()
 
+        self._dict["Profile sediment layers"] = _translate(
+            "SedimentLayers", "Profile sediment layers"
+        )
+
         self._sub_dict["table_headers"] = {
             "x": _translate("SedimentLayers", "X (m)"),
             "y": _translate("SedimentLayers", "Y (m)"),
diff --git a/src/View/SedimentLayers/Reach/SLDialog.py b/src/View/SedimentLayers/Reach/SLDialog.py
index 9f3c878b..b829d437 100644
--- a/src/View/SedimentLayers/Reach/SLDialog.py
+++ b/src/View/SedimentLayers/Reach/SLDialog.py
@@ -24,9 +24,9 @@ class SLDialog(PamhyrDialog):
     _pamhyr_ui = "SLDialog"
     _pamhyr_name = "SL"
 
-    def __init__(self, study=None, config=None, parent=None):
+    def __init__(self, study=None, config=None, trad=None, parent=None):
         super(SLDialog, self).__init__(
-            title=self._pamhyr_name,
+            title=trad[self._pamhyr_name],
             study=study,
             config=config,
             parent=parent
diff --git a/src/View/SedimentLayers/Reach/Window.py b/src/View/SedimentLayers/Reach/Window.py
index 854e06a5..1289dcf4 100644
--- a/src/View/SedimentLayers/Reach/Window.py
+++ b/src/View/SedimentLayers/Reach/Window.py
@@ -53,8 +53,9 @@ class ReachSedimentLayersWindow(PamhyrWindow):
         else:
             self._reach = reach
 
+        trad = SedimentReachTranslate()
         name = (
-            self._pamhyr_name + " - " +
+            trad[self._pamhyr_name] + " - " +
             study.name + " - " +
             self._reach.name
         )
@@ -63,7 +64,7 @@ class ReachSedimentLayersWindow(PamhyrWindow):
             title=name,
             study=study,
             config=config,
-            trad=SedimentReachTranslate(),
+            trad=trad,
             parent=parent
         )
 
@@ -165,6 +166,7 @@ class ReachSedimentLayersWindow(PamhyrWindow):
     def apply_sl_each_profile(self):
         slw = SLDialog(
             study=self._study,
+            trad=self._trad,
             parent=self
         )
         if slw.exec():
diff --git a/src/View/SedimentLayers/Reach/translate.py b/src/View/SedimentLayers/Reach/translate.py
index fd2d3bdb..8f97876d 100644
--- a/src/View/SedimentLayers/Reach/translate.py
+++ b/src/View/SedimentLayers/Reach/translate.py
@@ -1,3 +1,19 @@
+# translate.py -- Pamhyr
+# Copyright (C) 2024  INRAE
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
 # -*- coding: utf-8 -*-
 
 from PyQt5.QtCore import QCoreApplication
@@ -11,6 +27,13 @@ class SedimentReachTranslate(SedimentTranslate):
     def __init__(self):
         super(SedimentReachTranslate, self).__init__()
 
+        self._dict["Reach sediment layers"] = _translate(
+            "SedimentLayers", "Reach sediment layers"
+        )
+        self._dict["SL"] = _translate(
+            "SedimentLayers", "Apply sediment layers to reach"
+        )
+
         self._dict["nd"] = _translate("SedimentLayers", "Not defined")
         self._dict["kp"] = _translate("SedimentLayers", "Kp (m)")
         self._dict["height"] = _translate("SedimentLayers", "Height (m)")
diff --git a/src/View/SedimentLayers/Window.py b/src/View/SedimentLayers/Window.py
index 1ff2c7f9..ae36f2e9 100644
--- a/src/View/SedimentLayers/Window.py
+++ b/src/View/SedimentLayers/Window.py
@@ -59,15 +59,16 @@ class SedimentLayersWindow(PamhyrWindow):
     def __init__(self, study=None, config=None, parent=None):
         self._sediment_layers = study.river.sediment_layers
 
+        trad = SedimentTranslate()
         name = (
-            self._pamhyr_name + " - " + study.name
+            trad[self._pamhyr_name] + " - " + study.name
         )
 
         super(SedimentLayersWindow, self).__init__(
             title=name,
             study=study,
             config=config,
-            trad=SedimentTranslate(),
+            trad=trad,
             parent=parent
         )
 
diff --git a/src/View/SedimentLayers/translate.py b/src/View/SedimentLayers/translate.py
index 83a6169d..6f27fb3a 100644
--- a/src/View/SedimentLayers/translate.py
+++ b/src/View/SedimentLayers/translate.py
@@ -11,6 +11,10 @@ class SedimentTranslate(PamhyrTranslate):
     def __init__(self):
         super(SedimentTranslate, self).__init__()
 
+        self._dict["Sediment Layers List"] = _translate(
+            "SedimentLayers", "Sediment Layers List"
+        )
+
         self._sub_dict["table_headers"] = {
             "name": _translate("SedimentLayers", "Name"),
             "comment": _translate("SedimentLayers", "Comment"),
-- 
GitLab