added translation support for the UI
This commit is contained in:
parent
b727a3a9d6
commit
807aac3237
5 changed files with 37 additions and 5 deletions
BIN
assets/language/french.qm
Normal file
BIN
assets/language/french.qm
Normal file
Binary file not shown.
22
assets/language/french.ts
Normal file
22
assets/language/french.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="_FR">
|
||||||
|
<context>
|
||||||
|
<name>FrameSurvey</name>
|
||||||
|
<message>
|
||||||
|
<location filename="source/widget/FrameSurvey.py" line="54"/>
|
||||||
|
<source>ABANDON</source>
|
||||||
|
<translation>Abandonner</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="source/widget/FrameSurvey.py" line="60"/>
|
||||||
|
<source>SKIP</source>
|
||||||
|
<translation>Passer</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="source/widget/FrameSurvey.py" line="65"/>
|
||||||
|
<source>NEXT</source>
|
||||||
|
<translation>Suivant</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
11
main.py
11
main.py
|
@ -1,13 +1,24 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from PyQt6.QtCore import QTranslator
|
||||||
from PyQt6.QtWidgets import QApplication
|
from PyQt6.QtWidgets import QApplication
|
||||||
|
|
||||||
|
from source import assets_path
|
||||||
from source.widget import MyMainWindow
|
from source.widget import MyMainWindow
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# create the application
|
||||||
application = QApplication(sys.argv)
|
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 = MyMainWindow()
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
|
# start the application
|
||||||
application.exec()
|
application.exec()
|
||||||
|
|
|
@ -20,7 +20,6 @@ class FrameSurvey(QFrame):
|
||||||
signal_success = pyqtSignal()
|
signal_success = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, survey_path: Path | str):
|
def __init__(self, survey_path: Path | str):
|
||||||
# TODO: translation support
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# signals
|
# signals
|
||||||
|
@ -52,18 +51,18 @@ class FrameSurvey(QFrame):
|
||||||
|
|
||||||
self.button_abandon = QPushButton()
|
self.button_abandon = QPushButton()
|
||||||
self._layout_navigation.addWidget(self.button_abandon)
|
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.setStyleSheet("QPushButton { color : red; }")
|
||||||
self.button_abandon.clicked.connect(self.quit) # NOQA: connect exist
|
self.button_abandon.clicked.connect(self.quit) # NOQA: connect exist
|
||||||
|
|
||||||
self.button_skip = QPushButton()
|
self.button_skip = QPushButton()
|
||||||
self._layout_navigation.addWidget(self.button_skip)
|
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_skip.clicked.connect(self.next_survey) # NOQA: connect exist
|
||||||
|
|
||||||
self.button_forward = QPushButton()
|
self.button_forward = QPushButton()
|
||||||
self._layout_navigation.addWidget(self.button_forward)
|
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
|
self.button_forward.clicked.connect(self.next_survey) # NOQA: connect exist
|
||||||
|
|
||||||
# progress bar
|
# progress bar
|
||||||
|
|
|
@ -12,6 +12,6 @@ class MyMainWindow(QMainWindow):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.setWindowIcon(QIcon(str(icon_path.resolve())))
|
self.setWindowIcon(QIcon(str(icon_path.resolve())))
|
||||||
self.setWindowTitle("Sondage")
|
self.setWindowTitle(self.tr("SURVEY"))
|
||||||
|
|
||||||
self.setCentralWidget(widget.FrameSurvey("./surveys.json"))
|
self.setCentralWidget(widget.FrameSurvey("./surveys.json"))
|
||||||
|
|
Loading…
Reference in a new issue