diff --git a/src/View/BoundaryCondition/Edit/translate.py b/src/View/BoundaryCondition/Edit/translate.py index dd85fdfbdc275ec301352fc5ac7d39768b052a05..9d8355505cf0477acafa811fe48d16f33b04f695 100644 --- a/src/View/BoundaryCondition/Edit/translate.py +++ b/src/View/BoundaryCondition/Edit/translate.py @@ -18,7 +18,7 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate from View.BoundaryCondition.translate import BCTranslate @@ -36,9 +36,9 @@ class BCETranslate(BCTranslate): self._sub_dict["table_headers"] = { "x": _translate("BoundaryCondition", "X"), "y": _translate("BoundaryCondition", "Y"), - "time": _translate("BoundaryCondition", "Time"), - "date": _translate("BoundaryCondition", "Date"), - "discharge": _translate("BoundaryCondition", "Discharge (m³/s)"), - "z": _translate("BoundaryCondition", "Z (m)"), + "time": self._dict["time"], + "date": self._dict["date"], + "discharge": self._dict["unit_discharge"], + "z": self._dict["unit_elevation"], "solid": _translate("BoundaryCondition", "Solid (kg/s)"), } diff --git a/src/View/BoundaryCondition/translate.py b/src/View/BoundaryCondition/translate.py index a366f2a940034557b63b54a3006564ac0766c03f..81746fd9abfe0cdb90330c8529117da23ef2ddc8 100644 --- a/src/View/BoundaryCondition/translate.py +++ b/src/View/BoundaryCondition/translate.py @@ -18,7 +18,7 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate from Model.BoundaryCondition.BoundaryConditionTypes import ( NotDefined, PonctualContribution, @@ -38,7 +38,7 @@ BC_types = { } -class BCTranslate(PamhyrTranslate): +class BCTranslate(MainTranslate): def __init__(self): super(BCTranslate, self).__init__() @@ -56,7 +56,7 @@ class BCTranslate(PamhyrTranslate): } self._sub_dict["table_headers"] = { - "name": _translate("BoundaryCondition", "Name"), - "type": _translate("BoundaryCondition", "Type"), + "name": self._dict["name"], + "type": self._dict["type"], "node": _translate("BoundaryCondition", "Node") } diff --git a/src/View/CheckList/Translate.py b/src/View/CheckList/Translate.py index 29cf7693bf76920e1cb03f5faf1080a7a77c60cd..dfabecf7f7e1a715a21ee61f9e6e47f833c0da60 100644 --- a/src/View/CheckList/Translate.py +++ b/src/View/CheckList/Translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class CheckListTranslate(PamhyrTranslate): +class CheckListTranslate(MainTranslate): def __init__(self): super(CheckListTranslate, self).__init__() @@ -32,6 +32,6 @@ class CheckListTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - "name": _translate("CheckList", "Name"), + "name": self._dict["name"], "status": _translate("CheckList", "Status"), } diff --git a/src/View/Configure/Translate.py b/src/View/Configure/Translate.py index 29ac4c60b93d8666c66408a5d62955774fe8265b..be18234fe544921fea6502a7c7639cd8c1622412 100644 --- a/src/View/Configure/Translate.py +++ b/src/View/Configure/Translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class ConfigureTranslate(PamhyrTranslate): +class ConfigureTranslate(MainTranslate): def __init__(self): super(ConfigureTranslate, self).__init__() @@ -32,9 +32,9 @@ class ConfigureTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - "name": _translate("Configure", "Name"), - "type": _translate("Configure", "Type"), - "description": _translate("Configure", "Description"), + "name": self._dict["name"], + "type": self._dict["type"], + "description": self._dict["description"], } # Solvers diff --git a/src/View/Frictions/translate.py b/src/View/Frictions/translate.py index 9ec0655b162b94b8d65542b187048b735c6fee57..57b823a7db6e33e453ed5dc1be6c4b44c775d360 100644 --- a/src/View/Frictions/translate.py +++ b/src/View/Frictions/translate.py @@ -18,18 +18,16 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class FrictionsTranslate(PamhyrTranslate): +class FrictionsTranslate(MainTranslate): def __init__(self): super(FrictionsTranslate, self).__init__() - self._dict["kp"] = _translate( - "Frictions", "Kp (m)" - ) + self._dict["kp"] = self._dict["unit_kp"] self._dict["stricklers"] = _translate( "Frictions", "Stricklers" ) @@ -39,8 +37,8 @@ class FrictionsTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - # "name": _translate("Frictions", "Name"), - # "edge": _translate("Frictions", "Reach"), + # "name": self._dict["name"], + # "edge": self._dict["reach"], "begin_kp": _translate("Frictions", "Begin kp (m)"), "end_kp": _translate("Frictions", "End kp (m)"), "begin_strickler": _translate("Frictions", "Begin strickler"), diff --git a/src/View/Geometry/PlotAC.py b/src/View/Geometry/PlotAC.py index 940cfa1945a6079a8daa7018966ec44d634b6a6b..24567bef97f50b131c4dbc6d5c0e7ebdfb0c4bfa 100644 --- a/src/View/Geometry/PlotAC.py +++ b/src/View/Geometry/PlotAC.py @@ -21,12 +21,6 @@ import logging from tools import timer from View.Tools.PamhyrPlot import PamhyrPlot -from PyQt5.QtCore import ( - QCoreApplication -) - -_translate = QCoreApplication.translate - logger = logging.getLogger() @@ -46,20 +40,12 @@ class PlotAC(PamhyrPlot): self._auto_relim_update = True self._autoscale_update = True - self.label_x = _translate( - "Geometry", "Transverse abscissa (m)" - ) - self.label_y = _translate("Geometry", "Height (m)") + self.label_x = self._trad["transverse_abscissa"] + self.label_y = self._trad["unit_height"] - self.label_previous_plot_selected = _translate( - "Geometry", "Previous cross-section" - ) - self.label_plot_selected = _translate( - "Geometry", "Cross-section" - ) - self.label_next_plot_selected = _translate( - "Geometry", "Next cross-section" - ) + self.label_previous_plot_selected = self._trad["prev_cs"] + self.label_plot_selected = self._trad["cs"] + self.label_next_plot_selected = self._trad["next_cs"] self.previous_plot_selected = None self.plot_selected = None diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py index c3ca9653b4942216bf57147634dcea1a8811dedd..35e9ffabe00cd420a18f8443cdeec8312c462b89 100644 --- a/src/View/Geometry/PlotKPZ.py +++ b/src/View/Geometry/PlotKPZ.py @@ -21,12 +21,6 @@ import logging from tools import timer from View.Tools.PamhyrPlot import PamhyrPlot -from PyQt5.QtCore import ( - QCoreApplication -) - -_translate = QCoreApplication.translate - logger = logging.getLogger() @@ -48,8 +42,8 @@ class PlotKPZ(PamhyrPlot): self.line_kp_zmin_zmax = None self.line_kp_zmin_zmax_highlight = None - self.label_x = _translate("MainWindow_reach", "Kp (m)") - self.label_y = _translate("MainWindow_reach", "Height (m)") + self.label_x = self._trad["unit_kp"] + self.label_y = self._trad["unit_height"] self.before_plot_selected = None self.plot_selected = None diff --git a/src/View/Geometry/PlotXY.py b/src/View/Geometry/PlotXY.py index dcc2ac816158c25552838cb0f7ef1d57ec14bd35..4557c717911e761f9d67dfd190faf9b10e2020ec 100644 --- a/src/View/Geometry/PlotXY.py +++ b/src/View/Geometry/PlotXY.py @@ -40,8 +40,8 @@ class PlotXY(PamhyrPlot): self.line_xy = [] self.line_gl = [] - self.label_x = _translate("Geometry", "X (m)") - self.label_y = _translate("Geometry", "Y (m)") + self.label_x = self._trad["x"] + self.label_y = self._trad["y"] self.before_plot_selected = None self.plot_selected = None diff --git a/src/View/Geometry/Profile/Plot.py b/src/View/Geometry/Profile/Plot.py index 661533ed57701b3895983a17e14d4073707fb783..6cd62adf902a8e23fe899a90c92bb07dab5ab6a9 100644 --- a/src/View/Geometry/Profile/Plot.py +++ b/src/View/Geometry/Profile/Plot.py @@ -47,16 +47,18 @@ class Plot(PamhyrPlot): self.line_xy = [] self.line_gl = [] + self.label_x = self._trad["unit_kp"] + self.label_y = self._trad["unit_height"] + self.before_plot_selected = None self.plot_selected = None self.after_plot_selected = None + self._isometric_axis = False + @timer def draw(self): - self.canvas.axes.cla() - self.canvas.axes.grid( - color='grey', linestyle='--', linewidth=0.5 - ) + self.init_axes() x = self.data.get_station() y = self.data.z() @@ -71,19 +73,10 @@ class Plot(PamhyrPlot): gl = map(lambda p: p.name, self.data.points) self.profile_line2D, = self.canvas.axes.plot( - x, y, color='r', lw=1.5, - markersize=7, marker='+', + x, y, color=self.color_plot, + lw=1.5, markersize=7, marker='+', picker=30 ) - self.canvas.axes.set_xlabel( - _translate("MainWindowProfile", - "Transverse abscissa (m)"), - color='black', fontsize=10 - ) - self.canvas.axes.set_ylabel( - _translate("MainWindowProfile", "Height (m)"), - color='black', fontsize=10 - ) # Add label on graph self.annotation = [] @@ -142,10 +135,8 @@ class Plot(PamhyrPlot): self.onclick_event.onclick ) - self.canvas.figure.tight_layout() - self.canvas.figure.canvas.draw_idle() + self.idle() @timer - def update(self, ind=None): - logger.info("TODO: implemente update") + def update(self): self.draw() diff --git a/src/View/Geometry/Profile/Translate.py b/src/View/Geometry/Profile/Translate.py index 049563492c162e104b363c50ea27812c46b2a03c..249d17c7af08a77aa2b17d3d46e64632076d0cb9 100644 --- a/src/View/Geometry/Profile/Translate.py +++ b/src/View/Geometry/Profile/Translate.py @@ -18,7 +18,7 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate from View.Geometry.Translate import GeometryTranslate _translate = QCoreApplication.translate @@ -33,9 +33,9 @@ class GeometryProfileTranslate(GeometryTranslate): ) self._sub_dict["table_headers"] = { - "x": _translate("Geometry", "X (m)"), - "y": _translate("Geometry", "Y (m)"), - "z": _translate("Geometry", "Z (m)"), - "name": _translate("Geometry", "Name"), + "x": self._dict["x"], + "y": self._dict["y"], + "z": self._dict["z"], + "name": self._dict["name"], "abs": _translate("Geometry", "Traversal abs (m)"), } diff --git a/src/View/Geometry/Profile/Window.py b/src/View/Geometry/Profile/Window.py index 96468c7741589b943231fb5ef1c5af8e76bcf620..0ca3cbd308b53f820cf266b40b46126a0b8e7100 100644 --- a/src/View/Geometry/Profile/Window.py +++ b/src/View/Geometry/Profile/Window.py @@ -108,6 +108,7 @@ class ProfileWindow(PamhyrWindow): self._plot = Plot( canvas=self._canvas, data=self._profile, + trad=self._trad, toolbar=self._toolbar, table=self.find(QTableView, "tableView") ) diff --git a/src/View/Geometry/Translate.py b/src/View/Geometry/Translate.py index 6e380d17a9579ee6ec53b6e05d1e707cd5c322d8..7b607d83c537adb783a9242fef6ae383131b0b9b 100644 --- a/src/View/Geometry/Translate.py +++ b/src/View/Geometry/Translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class GeometryTranslate(PamhyrTranslate): +class GeometryTranslate(MainTranslate): def __init__(self): super(GeometryTranslate, self).__init__() @@ -38,17 +38,28 @@ class GeometryTranslate(PamhyrTranslate): "Geometry", "File mage meshed geometry (*.M *.m)") self._dict["file_all"] = _translate("Geometry", "All file (*)") - self._dict["reach"] = _translate("Geometry", "reach") - self._dict["reachs"] = _translate("Geometry", "reachs") - self._dict["cross_section"] = _translate("Geometry", "cross-section") self._dict["cross_sections"] = _translate("Geometry", "cross-sections") self._dict["profile"] = _translate("Geometry", "cross-section") self._dict["profiles"] = _translate("Geometry", "cross-sections") + self._dict["transverse_abscissa"] = _translate( + "Geometry", "Transverse abscissa (m)" + ) + + self._dict["prev_cs"] = _translate( + "Geometry", "Previous cross-section" + ) + self._dict["cs"] = _translate("Geometry", "Cross-section") + self._dict["next_cs"] = _translate("Geometry", "Next cross-section") + + self._dict["x"] = _translate("Geometry", "X (m)") + self._dict["y"] = _translate("Geometry", "Y (m)") + self._dict["z"] = _translate("Geometry", "Z (m)") + self._sub_dict["table_headers"] = { - "name": _translate("Geometry", "Name"), - "kp": _translate("Geometry", "KP (m)"), + "name": self._dict["name"], + "kp": self._dict["unit_kp"], "poins": _translate("Geometry", "Points"), } diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 75b014602f70233199d6837271bb420356be9d61..8aef38fbc56ea21faf7881a00fd4bcb64184ed72 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -327,6 +327,7 @@ class GeometryWindow(PamhyrWindow): self._plot_xy = PlotXY( canvas=self._canvas_xy, data=self._reach, + trad=self._trad, toolbar=self._toolbar_xy ) self._plot_xy.draw() @@ -344,6 +345,7 @@ class GeometryWindow(PamhyrWindow): self._plot_kpc = PlotKPZ( canvas=self._canvas_kpc, data=self._reach, + trad=self._trad, toolbar=self._toolbar_kpc ) self._plot_kpc.draw() @@ -361,6 +363,7 @@ class GeometryWindow(PamhyrWindow): self._plot_ac = PlotAC( canvas=self._canvas_ac, data=self._reach, + trad=self._trad, toolbar=self._toolbar_ac, ) self._plot_ac.draw() diff --git a/src/View/HydraulicStructures/BasicHydraulicStructures/Translate.py b/src/View/HydraulicStructures/BasicHydraulicStructures/Translate.py index 4c0bef285e636e05d3604915ffc82a0876104599..75921b750a79ff91216fe7dbefe4c8cf4a1b538a 100644 --- a/src/View/HydraulicStructures/BasicHydraulicStructures/Translate.py +++ b/src/View/HydraulicStructures/BasicHydraulicStructures/Translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class BasicHydraulicStructuresTranslate(PamhyrTranslate): +class BasicHydraulicStructuresTranslate(MainTranslate): def __init__(self): super(BasicHydraulicStructuresTranslate, self).__init__() @@ -44,18 +44,10 @@ hydraulic structure values?" # BHSValues translation - self._dict['width'] = _translate( - "BasicHydraulicStructures", "Width (m)" - ) - self._dict['height'] = _translate( - "BasicHydraulicStructures", "Thickness (m)" - ) - self._dict['elevation'] = _translate( - "BasicHydraulicStructures", "Elevation (m)" - ) - self._dict['diameter'] = _translate( - "BasicHydraulicStructures", "Diameter (m)" - ) + self._dict['width'] = self._dict["unit_width"] + self._dict['height'] = self._dict["unit_thickness"] + self._dict['elevation'] = self._dict["unit_elevation"] + self._dict['diameter'] = self._dict["unit_diameter"] self._dict['discharge_coefficient'] = _translate( "BasicHydraulicStructures", "Discharge coefficient" ) @@ -155,11 +147,11 @@ hydraulic structure values?" # Tables self._sub_dict["table_headers"] = { - "name": _translate("BasicHydraulicStructures", "Name"), - "type": _translate("BasicHydraulicStructures", "Type"), + "name": self._dict["name"], + "type": self._dict["type"], } self._sub_dict["table_headers_parameters"] = { - "name": _translate("BasicHydraulicStructures", "Name"), - "value": _translate("BasicHydraulicStructures", "Value"), + "name": self._dict["name"], + "value": self._dict["value"], } diff --git a/src/View/HydraulicStructures/PlotAC.py b/src/View/HydraulicStructures/PlotAC.py index 710b5af71764f5b331167557f395544606f8d7d3..c63dc9bfdef5fb2e311b54eb90cf85e4937a4b1c 100644 --- a/src/View/HydraulicStructures/PlotAC.py +++ b/src/View/HydraulicStructures/PlotAC.py @@ -20,12 +20,6 @@ from tools import timer from View.Tools.PamhyrPlot import PamhyrPlot from matplotlib import pyplot as plt -from PyQt5.QtCore import ( - QCoreApplication -) - -_translate = QCoreApplication.translate - class PlotAC(PamhyrPlot): def __init__(self, canvas=None, trad=None, toolbar=None, @@ -42,8 +36,8 @@ class PlotAC(PamhyrPlot): self._current_reach = reach self._current_profile = profile - self.label_x = _translate("MainWindow_reach", "X (m)") - self.label_y = _translate("MainWindow_reach", "Elevation (m)") + self.label_x = self._trad["x"] + self.label_y = self._trad["unit_elevation"] self._isometric_axis = False diff --git a/src/View/HydraulicStructures/PlotKPC.py b/src/View/HydraulicStructures/PlotKPC.py index a50c1cb4cbcadf2af80b49028ae05f8ccf4c4810..3327f6e627114ac8513dda1ca57670b0cdf722e8 100644 --- a/src/View/HydraulicStructures/PlotKPC.py +++ b/src/View/HydraulicStructures/PlotKPC.py @@ -43,8 +43,8 @@ class PlotKPC(PamhyrPlot): self._current_reach = reach self._current_profile = profile - self.label_x = _translate("MainWindow_reach", "KP (m)") - self.label_y = _translate("MainWindow_reach", "Elevation (m)") + self.label_x = self._trad["unit_kp"] + self.label_y = self._trad["unit_elevation"] self._isometric_axis = False diff --git a/src/View/HydraulicStructures/Translate.py b/src/View/HydraulicStructures/Translate.py index 2ad913539a828ee9d3d7f3ef0c96068642731f80..c82d90ff76eb1cc960f972bb23ee7e638df9421d 100644 --- a/src/View/HydraulicStructures/Translate.py +++ b/src/View/HydraulicStructures/Translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class HydraulicStructuresTranslate(PamhyrTranslate): +class HydraulicStructuresTranslate(MainTranslate): def __init__(self): super(HydraulicStructuresTranslate, self).__init__() @@ -31,8 +31,10 @@ class HydraulicStructuresTranslate(PamhyrTranslate): "HydraulicStructures", "Hydraulic Structures" ) + self._dict["x"] = _translate("HydraulicStructures", "X (m)") + self._sub_dict["table_headers"] = { - "name": _translate("HydraulicStructures", "Name"), - "reach": _translate("HydraulicStructures", "Reach"), - "kp": _translate("HydraulicStructures", "Kp (m)"), + "name": self._dict["name"], + "reach": self._dict["reach"], + "kp": self._dict["unit_kp"], } diff --git a/src/View/HydraulicStructures/Window.py b/src/View/HydraulicStructures/Window.py index e499617e9a86bbde868de7f2d2aa39c28e7dd507..ff290d7a6e95ae127ad0ea8f2b7f7cbdaa598318 100644 --- a/src/View/HydraulicStructures/Window.py +++ b/src/View/HydraulicStructures/Window.py @@ -52,8 +52,6 @@ from View.HydraulicStructures.BasicHydraulicStructures.Window import ( BasicHydraulicStructuresWindow ) -_translate = QCoreApplication.translate - logger = logging.getLogger() @@ -142,6 +140,7 @@ class HydraulicStructuresWindow(PamhyrWindow): river=self._study.river, reach=None, profile=None, + trad=self._trad, toolbar=self.toolbar ) self.plot_kpc.draw() @@ -160,6 +159,7 @@ class HydraulicStructuresWindow(PamhyrWindow): river=self._study.river, reach=None, profile=None, + trad=self._trad, toolbar=self.toolbar_2 ) self.plot_ac.draw() diff --git a/src/View/InitialConditions/translate.py b/src/View/InitialConditions/translate.py index e4a20d07682adbeaf6db162b85ea2e46b4815bb8..bd3c1eb3303fff9a7904311cee86b40ebde8e51d 100644 --- a/src/View/InitialConditions/translate.py +++ b/src/View/InitialConditions/translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class ICTranslate(PamhyrTranslate): +class ICTranslate(MainTranslate): def __init__(self): super(ICTranslate, self).__init__() @@ -34,18 +34,16 @@ class ICTranslate(PamhyrTranslate): self._dict["Height"] = _translate( "InitialCondition", "Height") - self._dict["elevation"] = _translate( - "InitialCondition", "Elevation (m)") - self._dict["discharge"] = _translate( - "InitialCondition", "Discharge (m³/s)") - self._dict["kp"] = _translate("InitialCondition", "KP (m)") + self._dict["elevation"] = self._dict["unit_elevation"] + self._dict["discharge"] = self._dict["unit_discharge"] + self._dict["kp"] = self._dict["unit_kp"] self._sub_dict["table_headers"] = { # "name": _translate("InitialCondition", "Name"), - "kp": _translate("InitialCondition", "KP (m)"), + "kp": self._dict["unit_kp"], # "speed": _translate("InitialCondition", "Speed (m/s)"), - "discharge": _translate("InitialCondition", "Discharge (m³/s)"), - "elevation": _translate("InitialCondition", "Elevation (m)"), - "height": _translate("InitialCondition", "Height (m)"), + "discharge": self._dict["unit_discharge"], + "elevation": self._dict["unit_elevation"], + "height": self._dict["unit_height"], # "comment": _translate("InitialCondition", "Comment"), } diff --git a/src/View/LateralContribution/Edit/translate.py b/src/View/LateralContribution/Edit/translate.py index 14ed87c4dba4276fe293530a19a1730e6f2446e1..eeb889304838a4b75339bfdcb481d6de96e55b4c 100644 --- a/src/View/LateralContribution/Edit/translate.py +++ b/src/View/LateralContribution/Edit/translate.py @@ -18,7 +18,7 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate from View.LateralContribution.translate import LCTranslate _translate = QCoreApplication.translate @@ -34,8 +34,8 @@ class LCETranslate(LCTranslate): self._sub_dict["table_headers"] = { "x": _translate("LateralContribution", "X"), "y": _translate("LateralContribution", "Y"), - "time": _translate("LateralContribution", "Time"), - "date": _translate("LateralContribution", "Date"), - "discharge": _translate("LateralContribution", "Discharge (m³/s)"), - "z": _translate("LateralContribution", "Z (m)") + "time": self._dict["time"], + "date": self._dict["date"], + "discharge": self._dict["unit_discharge"], + "z": self._dict["unit_elevation"], } diff --git a/src/View/LateralContribution/translate.py b/src/View/LateralContribution/translate.py index 5b19de44a14c9c9320179509abab4c28441f53c8..1e955cf9ead54c8e1f03b96458004b2a162fbe02 100644 --- a/src/View/LateralContribution/translate.py +++ b/src/View/LateralContribution/translate.py @@ -18,7 +18,7 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate from Model.LateralContribution.LateralContributionTypes import ( NotDefined, LateralContrib, Rain, Evaporation, @@ -34,7 +34,7 @@ LC_types = { } -class LCTranslate(PamhyrTranslate): +class LCTranslate(MainTranslate): def __init__(self): super(LCTranslate, self).__init__() @@ -50,9 +50,9 @@ class LCTranslate(PamhyrTranslate): } self._sub_dict["table_headers"] = { - "name": _translate("LateralContribution", "Name"), - "type": _translate("LateralContribution", "Type"), - "edge": _translate("LateralContribution", "Reach"), + "name": self._dict["name"], + "type": self._dict["type"], + "edge": self._dict["reach"], "begin_kp": _translate("LateralContribution", "Begin kp (m)"), "end_kp": _translate("LateralContribution", "End kp (m)") } diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 231cf1b376a0a4059a232f0fd99b0524b27b1021..45dfca3c6566c0bc273088980646b0f4485b81ca 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -42,6 +42,8 @@ from View.Tools.ASubWindow import WindowToolKit from View.Tools.ListedSubWindow import ListedSubWindow from View.DummyWindow import DummyWindow +from View.Translate import MainTranslate + from View.Configure.Window import ConfigureWindow from View.Study.Window import NewStudyWindow from View.About.Window import AboutWindow @@ -73,8 +75,6 @@ except Exception as e: from Model.Study import Study -_translate = QCoreApplication.translate - logger = logging.getLogger() no_model_action = [ @@ -128,6 +128,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # Model self._study = None + # Translate + self._trad = MainTranslate() + # Results self._last_solver = None self._last_results = None @@ -145,9 +148,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): self.setup_results() self.setup_timer() - self.trans = QTranslator(self) - # self.ui.retranslateUi() - if not self.conf.close_correctly: if self.conf.last_study != "": self.dialog_reopen_study() @@ -305,18 +305,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): if init: self.debug_action = QAction("Debug", self) - self.debug_action.setToolTip( - _translate("MainWindow", "Open debug window") - ) + self.debug_action.setToolTip(self._trad["open_debug"]) self.debug_action.triggered.connect(self.open_debug) self.debug_sqlite_action = QAction("Debug SQLite", self) - self.debug_sqlite_action.setToolTip( - _translate( - "MainWindow", - "Open SQLite debuging tool ('sqlitebrowser')" - ) - ) + self.debug_sqlite_action.setToolTip(self._trad["open_debug_sql"]) self.debug_sqlite_action.triggered.connect(self.open_sqlite) if self.conf.debug: @@ -635,9 +628,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): return lambda: self._activate_window(h) action = QAction(window._title, self) - action.setToolTip( - _translate("MainWindow", "Activate this window") - ) + action.setToolTip(self._trad["active_window"]) h = window.hash() fn = lambda_generator(h) action.triggered.connect(fn) diff --git a/src/View/Network/translate.py b/src/View/Network/translate.py index 5c9dc5b810ee6109623246c312851fade04cf61c..089dc9a13aabc3903155ea52141718a2947a4856 100644 --- a/src/View/Network/translate.py +++ b/src/View/Network/translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class NetworkTranslate(PamhyrTranslate): +class NetworkTranslate(MainTranslate): def __init__(self): super(NetworkTranslate, self).__init__() @@ -32,12 +32,12 @@ class NetworkTranslate(PamhyrTranslate): ) self._sub_dict["table_headers_node"] = { - "name": _translate("Network", "Name"), - "type": _translate("Network", "Type"), + "name": self._dict['name'], + "type": self._dict['type'], } self._sub_dict["table_headers_edge"] = { - "name": _translate("Network", "Name"), + "name": self._dict['name'], "node1": _translate("Network", "Source node"), "node2": _translate("Network", "Destination node"), } diff --git a/src/View/Reservoir/Edit/Translate.py b/src/View/Reservoir/Edit/Translate.py index 74fea3a50055f09a404f8b892e173749810edbfe..657cad0d09885195e7152b5871a31873f9c7dc4f 100644 --- a/src/View/Reservoir/Edit/Translate.py +++ b/src/View/Reservoir/Edit/Translate.py @@ -18,7 +18,7 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate from View.Reservoir.Translate import ReservoirTranslate @@ -34,6 +34,6 @@ class EditReservoirTranslate(ReservoirTranslate): ) self._sub_dict["table_headers"] = { - "z": _translate("Reservoir", "Elevation (m)"), - "Area": _translate("Reservoir", "Area (hectare)"), + "z": self._dict["unit_elevation"], + "Area": self._dict["unit_area"], } diff --git a/src/View/Reservoir/Translate.py b/src/View/Reservoir/Translate.py index 0ba0beac81da3bbfc687a3d5b60a4a03a5bff117..f33e6d5a8da5fe43e87c5fabdb680fe183311ac6 100644 --- a/src/View/Reservoir/Translate.py +++ b/src/View/Reservoir/Translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class ReservoirTranslate(PamhyrTranslate): +class ReservoirTranslate(MainTranslate): def __init__(self): super(ReservoirTranslate, self).__init__() @@ -32,6 +32,6 @@ class ReservoirTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - "name": _translate("Reservoir", "Name"), - "node": _translate("Reservoir", "Node") + "name": self._dict["name"], + "node": _translate("Reservoir", "Node"), } diff --git a/src/View/Results/CustomPlot/Translate.py b/src/View/Results/CustomPlot/Translate.py index f87ac2906e8e8de19666c6ed04a339c891e08ade..6c4236b8603f5a555cebba9adb0c1ad9db757f83 100644 --- a/src/View/Results/CustomPlot/Translate.py +++ b/src/View/Results/CustomPlot/Translate.py @@ -33,30 +33,20 @@ class CustomPlotTranslate(ResultsTranslate): # Value type - self._dict['time'] = _translate( - "CustomPlot", "Time (sec)" - ) - self._dict['kp'] = _translate( - "CustomPlot", "Kp (m)" - ) + self._dict['time'] = self._dict["unit_time_s"] + self._dict['kp'] = self._dict["unit_kp"] + self._dict['water_elevation'] = self._dict["unit_water_elevation"] + self._dict['discharge'] = self._dict["unit_discharge"] self._dict['elevation'] = _translate( "CustomPlot", "Bed load elevation (m)" ) - self._dict['water_elevation'] = _translate( - "CustomPlot", "Water elevation (m)" - ) - self._dict['discharge'] = _translate( - "CustomPlot", "Discharge (m³/s)" - ) # Unit corresponding long name (plot axes display) self._dict['0-meter'] = _translate( "CustomPlot", "Bed load elevation (m)" ) - self._dict['1-m3s'] = _translate( - "CustomPlot", "Discharge (m³/s)" - ) + self._dict['1-m3s'] = self._dict["unit_discharge"] # SubDict diff --git a/src/View/Results/PlotAC.py b/src/View/Results/PlotAC.py index 97aebee157be766a69051454c98c485de6055dea..5da1edd1da9e600353b48df335b2f1111908a999 100644 --- a/src/View/Results/PlotAC.py +++ b/src/View/Results/PlotAC.py @@ -43,12 +43,12 @@ class PlotAC(PamhyrPlot): self._current_reach_id = reach_id self._current_profile_id = profile_id - self.label_x = _translate("Results", "X (m)") - self.label_y = _translate("MainWindow_reach", "Elevation (m)") + self.label_x = self._trad['x'] + self.label_y = self._trad["unit_elevation"] - self.label_bottom = _translate("Results", "River bottom") - self.label_water = _translate("Results", "Water elevation") - self.label_water_max = _translate("Results", "Max water elevation") + self.label_bottom = self._trad['label_bottom'] + self.label_water = self._trad['label_water'] + self.label_water_max = self._trad['label_water_max'] self._isometric_axis = False diff --git a/src/View/Results/PlotKPC.py b/src/View/Results/PlotKPC.py index 35f0b211e3ef8c88dee4fe61a8b86f96d02d5ac4..1cab022e0caf86727dc8374564f985d125cc53c7 100644 --- a/src/View/Results/PlotKPC.py +++ b/src/View/Results/PlotKPC.py @@ -29,8 +29,6 @@ from PyQt5.QtCore import ( logger = logging.getLogger() -_translate = QCoreApplication.translate - class PlotKPC(PamhyrPlot): def __init__(self, canvas=None, trad=None, toolbar=None, @@ -49,12 +47,12 @@ class PlotKPC(PamhyrPlot): self._current_reach_id = reach_id self._current_profile_id = profile_id - self.label_x = _translate("Results", "KP (m)") - self.label_y = _translate("Results", "Elevation (m)") + self.label_x = self._trad["unit_kp"] + self.label_y = self._trad["unit_elevation"] - self.label_bottom = _translate("Results", "River bottom") - self.label_water = _translate("Results", "Water elevation") - self.label_water_max = _translate("Results", "Max water elevation") + self.label_bottom = self._trad["label_bottom"] + self.label_water = self._trad["label_water"] + self.label_water_max = self._trad["label_water_max"] self._isometric_axis = False diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index 662db3956316babea3b5cf9c90f9f103ae6de154..f154eb3db9e5c4eab6596f41bb5344e65bd9ef3f 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -171,6 +171,7 @@ class ResultsWindow(PamhyrWindow): results=self._results, reach_id=0, profile_id=0, + trad=self._trad, toolbar=self.toolbar, display_current=True ) @@ -190,6 +191,7 @@ class ResultsWindow(PamhyrWindow): results=self._results, reach_id=0, profile_id=0, + trad=self._trad, toolbar=self.toolbar_2 ) self.plot_kpc.draw() @@ -208,6 +210,7 @@ class ResultsWindow(PamhyrWindow): results=self._results, reach_id=0, profile_id=0, + trad=self._trad, toolbar=self.toolbar_3 ) self.plot_ac.draw() @@ -227,6 +230,7 @@ class ResultsWindow(PamhyrWindow): results=self._results, reach_id=0, profile_id=0, + trad=self._trad, toolbar=self.toolbar_4 ) self.plot_h.draw() diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index 9dffa6f0b8bc1e8f637bd28f451680ed08277cb9..5f28c7f8ed78222303bcd453a66baea72783cab8 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -18,24 +18,27 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class ResultsTranslate(PamhyrTranslate): +class ResultsTranslate(MainTranslate): def __init__(self): super(ResultsTranslate, self).__init__() - self._dict["Results"] = _translate( - "Results", "Results" - ) + self._dict["Results"] = _translate("Results", "Results") - self._dict['day'] = _translate( - "Results", "day" - ) - self._dict['days'] = _translate( - "Results", "days" + self._dict['day'] = _translate("Results", "day") + self._dict['days'] = _translate("Results", "days") + + self._dict['x'] = _translate("Results", "X (m)") + + self._dict['label_bottom'] = _translate("Results", "River bottom") + self._dict['label_water'] = _translate("Results", "Water elevation") + self._dict['label_water_max'] = _translate( + "Results", + "Max water elevation" ) self._sub_dict["table_headers_reach"] = { @@ -43,12 +46,12 @@ class ResultsTranslate(PamhyrTranslate): } self._sub_dict["table_headers_profile"] = { - "name": _translate("Results", "Name"), - "kp": _translate("Results", "KP (m)"), + "name": self._dict["name"], + "kp": self._dict["unit_kp"], } self._sub_dict["table_headers_raw_data"] = { "name": _translate("Results", "Profile"), - "water_elevation": _translate("Results", "Water elevation (m)"), - "discharge": _translate("Results", "Discharge (m³/s)"), + "water_elevation": self._dict["unit_water_elevation"], + "discharge": self._dict["unit_discharge"], } diff --git a/src/View/SedimentLayers/Edit/translate.py b/src/View/SedimentLayers/Edit/translate.py index a9f82cb6d0edf8a8c16dfbf0a9a724ac1fa8cd0f..ba6e46eb6d742e79d8a4741a4ee804d3a4990f3e 100644 --- a/src/View/SedimentLayers/Edit/translate.py +++ b/src/View/SedimentLayers/Edit/translate.py @@ -31,14 +31,15 @@ class SedimentEditTranslate(SedimentTranslate): "SedimentLayers", "Edit Sediment Layers" ) - self._dict["height"] = _translate("SedimentLayers", "Thickness (m)") + self._dict["height"] = self._dict["unit_thickness"] self._sub_dict["table_headers"] = { - "name": _translate("SedimentLayers", "Name"), - # "type": _translate("SedimentLayers", "Type"), - "height": _translate("SedimentLayers", "Thickness (m)"), + "name": self._dict["name"], + # "type": self._dict["type"], + "height": self._dict["unit_thickness"], "d50": _translate("SedimentLayers", "D50"), "sigma": _translate("SedimentLayers", "Sigma"), - "critical_constraint": _translate("SedimentLayers", - "Critical constraint"), + "critical_constraint": _translate( + "SedimentLayers", "Critical constraint" + ), } diff --git a/src/View/SedimentLayers/Reach/Profile/translate.py b/src/View/SedimentLayers/Reach/Profile/translate.py index 382bc8d25822b58d33a258248b07d90a76165460..c6bef26750f121c4ad1d055f9465f16b354cbb5c 100644 --- a/src/View/SedimentLayers/Reach/Profile/translate.py +++ b/src/View/SedimentLayers/Reach/Profile/translate.py @@ -30,9 +30,7 @@ class SedimentProfileTranslate(SedimentReachTranslate): self._dict["x"] = _translate( "SedimentLayers", "X (m)" ) - self._dict["height"] = _translate( - "SedimentLayers", "Height (m)" - ) + self._dict["height"] = self._dict["unit_height"] self._dict["Profile sediment layers"] = _translate( "SedimentLayers", "Profile sediment layers" @@ -42,6 +40,6 @@ class SedimentProfileTranslate(SedimentReachTranslate): "x": _translate("SedimentLayers", "X (m)"), "y": _translate("SedimentLayers", "Y (m)"), "z": _translate("SedimentLayers", "Z (m)"), - "name": _translate("SedimentLayers", "Name"), + "name": self._dict["name"], "sl": _translate("SedimentLayers", "Sediment layers"), } diff --git a/src/View/SedimentLayers/Reach/translate.py b/src/View/SedimentLayers/Reach/translate.py index 8f97876d2449acf55823ff483ef75f199271da81..eb3f3cf0aab8e3a5ec8a32d950acbab249d3557b 100644 --- a/src/View/SedimentLayers/Reach/translate.py +++ b/src/View/SedimentLayers/Reach/translate.py @@ -35,11 +35,11 @@ class SedimentReachTranslate(SedimentTranslate): ) self._dict["nd"] = _translate("SedimentLayers", "Not defined") - self._dict["kp"] = _translate("SedimentLayers", "Kp (m)") - self._dict["height"] = _translate("SedimentLayers", "Height (m)") + self._dict["kp"] = self._dict["unit_kp"] + self._dict["height"] = self._dict["unit_height"] self._sub_dict["table_headers"] = { - "name": _translate("SedimentLayers", "Name"), - "kp": _translate("SedimentLayers", "KP (m)"), + "name": self._dict["name"], + "kp": self._dict["unit_kp"], "sl": _translate("SedimentLayers", "Sediment layers"), } diff --git a/src/View/SedimentLayers/translate.py b/src/View/SedimentLayers/translate.py index 4dc64b38d654b6c0f30bf4587e87beda45dcc17d..71fccf6ebc6bc98702a1c81e64ff9add5edaa2e5 100644 --- a/src/View/SedimentLayers/translate.py +++ b/src/View/SedimentLayers/translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class SedimentTranslate(PamhyrTranslate): +class SedimentTranslate(MainTranslate): def __init__(self): super(SedimentTranslate, self).__init__() @@ -32,6 +32,6 @@ class SedimentTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - "name": _translate("SedimentLayers", "Name"), - "comment": _translate("SedimentLayers", "Comment"), + "name": self._dict["name"], + "comment": self._dict["comment"], } diff --git a/src/View/SolverParameters/translate.py b/src/View/SolverParameters/translate.py index e753ef8afbaa8e7d2725318fc8b7f237ac37a976..c1a45d2bb9128232685d5cf3c3e1919e59b1e80c 100644 --- a/src/View/SolverParameters/translate.py +++ b/src/View/SolverParameters/translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class ParamTranslate(PamhyrTranslate): +class ParamTranslate(MainTranslate): def __init__(self): super(ParamTranslate, self).__init__() @@ -32,8 +32,8 @@ class ParamTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - "name": _translate("SolverParameters", "Name"), - "value": _translate("SolverParameters", "Value") + "name": self._dict["name"], + "value": self._dict["value"], } self._sub_dict["yes_no"] = { diff --git a/src/View/Stricklers/translate.py b/src/View/Stricklers/translate.py index 0733ca2d79e6f9b12c2ec3ba75eb8490663702ea..01275bb1f23bca223834b55356eea15001363482 100644 --- a/src/View/Stricklers/translate.py +++ b/src/View/Stricklers/translate.py @@ -18,12 +18,12 @@ from PyQt5.QtCore import QCoreApplication -from View.Tools.PamhyrTranslate import PamhyrTranslate +from View.Translate import MainTranslate _translate = QCoreApplication.translate -class StricklersTranslate(PamhyrTranslate): +class StricklersTranslate(MainTranslate): def __init__(self): super(StricklersTranslate, self).__init__() @@ -32,8 +32,8 @@ class StricklersTranslate(PamhyrTranslate): ) self._sub_dict["table_headers"] = { - "name": _translate("Stricklers", "Name"), - "minor": _translate("Stricklers", "Main channel"), - "medium": _translate("Stricklers", "Floodway"), - "comment": _translate("Stricklers", "Comment"), + "name": self._dict["name"], + "minor": self._dict["main_channel"], + "medium": self._dict["floodway"], + "comment": self._dict["comment"], } diff --git a/src/View/Translate.py b/src/View/Translate.py new file mode 100644 index 0000000000000000000000000000000000000000..87297cea05eab9d5d05e996a8c68216919542f6d --- /dev/null +++ b/src/View/Translate.py @@ -0,0 +1,81 @@ +# Translate.py -- Pamhyr +# 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 +# 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 + +from View.Tools.PamhyrTranslate import PamhyrTranslate + +_translate = QCoreApplication.translate + + +class CommonWordTranslate(PamhyrTranslate): + def __init__(self): + super(CommonWordTranslate, self).__init__() + + self._dict["name"] = _translate("CommonWord", "Name") + self._dict["type"] = _translate("CommonWord", "Type") + self._dict["value"] = _translate("CommonWord", "Value") + self._dict["comment"] = _translate("CommonWord", "Comment") + self._dict["description"] = _translate("CommonWord", "Description") + + self._dict["time"] = _translate("CommonWord", "Time") + self._dict["date"] = _translate("CommonWord", "Date") + + self._dict["reach"] = _translate("CommonWord", "Reach") + self._dict["reaches"] = _translate("CommonWord", "Reaches") + self._dict["cross_section"] = _translate("CommonWord", "Coss-section") + self._dict["main_channel"] = _translate("CommonWord", "Main channel") + self._dict["floodway"] = _translate("CommonWord", "Floodway") + + +class UnitTranslate(CommonWordTranslate): + def __init__(self): + super(UnitTranslate, self).__init__() + + self._dict["unit_kp"] = _translate("Unit", "KP (m)") + self._dict["unit_width"] = _translate("Unit", "Width (m)") + self._dict["unit_height"] = _translate("Unit", "Height (m)") + self._dict["unit_diameter"] = _translate("Unit", "Diameter (m)") + self._dict["unit_thickness"] = _translate("Unit", "Thickness (m)") + self._dict["unit_elevation"] = _translate("Unit", "Elevation (m)") + self._dict["unit_water_elevation"] = _translate( + "Unit", "Water elevation (m)" + ) + self._dict["unit_discharge"] = _translate("Unit", "Discharge (m³/s)") + self._dict["unit_area"] = _translate("Unit", "Area (hectare)"), + + self._dict["unit_time_s"] = _translate("Unit", "Time (sec)") + self._dict["unit_time_p"] = _translate("Unit", "Time (JJJ:HH:MM:SS)") + + self._dict["unit_date_s"] = _translate("Unit", "Date (sec)") + self._dict["unit_date_iso"] = _translate("Unit", "Date (ISO format)") + + +class MainTranslate(UnitTranslate): + def __init__(self): + super(MainTranslate, self).__init__() + + self._dict["open_debug"] = _translate( + "MainWindow", "Open debug window" + ) + self._dict["open_debug_sql"] = _translate( + "MainWindow", "Open SQLite debuging tool ('sqlitebrowser')" + ) + self._dict["active_window"] = _translate( + "MainWindow", "Activate this window" + ) diff --git a/src/tools.py b/src/tools.py index 817ac5fafec8581f4869ecb83b22ab56f9543537..0e4fe40e4a0692c3d929edf9975949956591263a 100644 --- a/src/tools.py +++ b/src/tools.py @@ -252,7 +252,6 @@ def old_pamhyr_date_to_timestamp(date: str): def timestamp_to_old_pamhyr_date(time: int): - logger.debug(f"timestamp_to_old_pamhyr_date({time}: {type(time)})") t0 = datetime.fromtimestamp(0) # HACK: Windows do not accept negative timestamps