diff --git a/assets/language/french.qm b/assets/language/french.qm new file mode 100644 index 0000000..e007924 Binary files /dev/null and b/assets/language/french.qm differ diff --git a/assets/language/french.ts b/assets/language/french.ts new file mode 100644 index 0000000..5787546 --- /dev/null +++ b/assets/language/french.ts @@ -0,0 +1,22 @@ + + + + + FrameSurvey + + + ABANDON + Abandonner + + + + SKIP + Passer + + + + NEXT + Suivant + + + diff --git a/main.py b/main.py index 3c1aa2e..919afe0 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,24 @@ import sys + +from PyQt6.QtCore import QTranslator from PyQt6.QtWidgets import QApplication +from source import assets_path from source.widget import MyMainWindow if __name__ == "__main__": + # create the application application = QApplication(sys.argv) + # load the translator to support multiple languages + translator = QTranslator() + application.installTranslator(translator) + translator.load(str(assets_path / "language/french.qm")) + + # create the window window = MyMainWindow() window.show() + # start the application application.exec() diff --git a/source/widget/FrameSurvey.py b/source/widget/FrameSurvey.py index dcd8af1..c6badfd 100644 --- a/source/widget/FrameSurvey.py +++ b/source/widget/FrameSurvey.py @@ -20,7 +20,6 @@ class FrameSurvey(QFrame): signal_success = pyqtSignal() def __init__(self, survey_path: Path | str): - # TODO: translation support super().__init__() # signals @@ -52,18 +51,18 @@ class FrameSurvey(QFrame): self.button_abandon = QPushButton() self._layout_navigation.addWidget(self.button_abandon) - self.button_abandon.setText("Abandonner") + self.button_abandon.setText(self.tr("ABANDON")) self.button_abandon.setStyleSheet("QPushButton { color : red; }") self.button_abandon.clicked.connect(self.quit) # NOQA: connect exist self.button_skip = QPushButton() self._layout_navigation.addWidget(self.button_skip) - self.button_skip.setText("Passer") + self.button_skip.setText(self.tr("SKIP")) self.button_skip.clicked.connect(self.next_survey) # NOQA: connect exist self.button_forward = QPushButton() self._layout_navigation.addWidget(self.button_forward) - self.button_forward.setText("Suivant") + self.button_forward.setText(self.tr("NEXT")) self.button_forward.clicked.connect(self.next_survey) # NOQA: connect exist # progress bar diff --git a/source/widget/MyMainWindow.py b/source/widget/MyMainWindow.py index 47fccc7..b942dc6 100644 --- a/source/widget/MyMainWindow.py +++ b/source/widget/MyMainWindow.py @@ -12,6 +12,6 @@ class MyMainWindow(QMainWindow): super().__init__() self.setWindowIcon(QIcon(str(icon_path.resolve()))) - self.setWindowTitle("Sondage") + self.setWindowTitle(self.tr("SURVEY")) self.setCentralWidget(widget.FrameSurvey("./surveys.json"))