tweaked some translation system

This commit is contained in:
Faraphel 2024-01-01 13:25:41 +01:00
parent 10e921ea23
commit e7d43371bb
10 changed files with 60 additions and 32 deletions

Binary file not shown.

View file

@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1" language="en"> <TS version="2.1" language="en">
<context>
<name>LanguageSelection</name>
<message>
<location filename="../../source/ui/LanguageSelection.py" line="70"/>
<source>SELECT YOUR LANGUAGE</source>
<translation>Select your language</translation>
</message>
<message>
<location filename="../../source/ui/LanguageSelection.py" line="71"/>
<source>START</source>
<translation>Start</translation>
</message>
</context>
<context> <context>
<name>SurveyEngine</name> <name>SurveyEngine</name>
<message> <message>
@ -27,12 +40,4 @@
<translation>Next</translation> <translation>Next</translation>
</message> </message>
</context> </context>
<context>
<name>SurveyWindow</name>
<message>
<location filename="../../source/ui/SurveyWindow.py" line="17"/>
<source>SURVEY</source>
<translation>Survey</translation>
</message>
</context>
</TS> </TS>

Binary file not shown.

View file

@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1" language="es"> <TS version="2.1" language="es">
<context>
<name>LanguageSelection</name>
<message>
<location filename="../../source/ui/LanguageSelection.py" line="70"/>
<source>SELECT YOUR LANGUAGE</source>
<translation>Seleccione su idioma</translation>
</message>
<message>
<location filename="../../source/ui/LanguageSelection.py" line="71"/>
<source>START</source>
<translation>Comenzar</translation>
</message>
</context>
<context> <context>
<name>SurveyEngine</name> <name>SurveyEngine</name>
<message> <message>
@ -27,12 +40,4 @@
<translation>Siguiente</translation> <translation>Siguiente</translation>
</message> </message>
</context> </context>
<context>
<name>SurveyWindow</name>
<message>
<location filename="../../source/ui/SurveyWindow.py" line="17"/>
<source>SURVEY</source>
<translation>Encuesta</translation>
</message>
</context>
</TS> </TS>

Binary file not shown.

View file

@ -1,12 +1,25 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1" language="fr_FR"> <TS version="2.1" language="fr_FR">
<context>
<name>LanguageSelection</name>
<message>
<location filename="../../source/ui/LanguageSelection.py" line="70"/>
<source>SELECT YOUR LANGUAGE</source>
<translation>Sélectionner votre langue</translation>
</message>
<message>
<location filename="../../source/ui/LanguageSelection.py" line="71"/>
<source>START</source>
<translation>Démarrer</translation>
</message>
</context>
<context> <context>
<name>SurveyEngine</name> <name>SurveyEngine</name>
<message> <message>
<location filename="../../source/ui/SurveyEngine.py" line="177"/> <location filename="../../source/ui/SurveyEngine.py" line="177"/>
<source>WARNING</source> <source>WARNING</source>
<translation>Avertissement</translation> <translation>Attention</translation>
</message> </message>
</context> </context>
<context> <context>
@ -27,12 +40,4 @@
<translation>Suivant</translation> <translation>Suivant</translation>
</message> </message>
</context> </context>
<context>
<name>SurveyWindow</name>
<message>
<location filename="../../source/ui/SurveyWindow.py" line="17"/>
<source>SURVEY</source>
<translation>Sondage</translation>
</message>
</context>
</TS> </TS>

View file

@ -5,6 +5,7 @@ from typing import Optional
import nextcord import nextcord
import requests import requests
from PyQt6.QtCore import pyqtSignal from PyQt6.QtCore import pyqtSignal
from PyQt6.QtWidgets import QApplication
result_path = Path("./results/") result_path = Path("./results/")
@ -59,6 +60,7 @@ def upload_discord(
except Exception as exc: except Exception as exc:
if signal_warning is not None: if signal_warning is not None:
signal_warning.emit("COULD NOT UPLOAD THE DATA") # NOQA: emit exist application = QApplication.instance()
signal_warning.emit(application.tr("COULD NOT UPLOAD THE DATA")) # NOQA: emit exist
else: else:
raise exc raise exc

View file

@ -19,7 +19,6 @@ class LanguageSelection(QWidget):
# title # title
self.title = QLabel() self.title = QLabel()
self._layout.addWidget(self.title) self._layout.addWidget(self.title)
self.title.setText("Select your language.")
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter) self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
# language selection # language selection
@ -40,13 +39,17 @@ class LanguageSelection(QWidget):
if language == language_default: if language == language_default:
self.select_language.setCurrentIndex(i) self.select_language.setCurrentIndex(i)
self.select_language.currentIndexChanged.connect(self.refresh_language) # NOQA: connect exist
# start button # start button
self.button_start = QPushButton() self.button_start = QPushButton()
self._layout.addWidget(self.button_start) self._layout.addWidget(self.button_start)
self.button_start.setText("Start")
self.button_start.clicked.connect(self.start) # NOQA: connect exist self.button_start.clicked.connect(self.start) # NOQA: connect exist
def start(self) -> None: # refresh the texts
self.refresh_language()
def refresh_language(self):
language_code = self.select_language.currentData() language_code = self.select_language.currentData()
# load the correct translator # load the correct translator
@ -60,6 +63,14 @@ class LanguageSelection(QWidget):
application = QApplication.instance() application = QApplication.instance()
application.installTranslator(translator) application.installTranslator(translator)
# refresh the texts
self.retranslate()
def retranslate(self):
self.title.setText(self.tr("SELECT YOUR LANGUAGE"))
self.button_start.setText(self.tr("START"))
def start(self) -> None:
# call the after event # call the after event
self.after() self.after()

View file

@ -175,5 +175,5 @@ class SurveyEngine(QWidget):
QMessageBox.warning( QMessageBox.warning(
self, self,
self.tr("WARNING"), self.tr("WARNING"),
self.tr(message), message,
) )

View file

@ -3,7 +3,7 @@ from pathlib import Path
from PyQt6.QtGui import QIcon from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QMainWindow from PyQt6.QtWidgets import QMainWindow
from source import ui, assets_path, __icon_png__ from source import ui, assets_path, __icon_png__, __appname__
icon_path = assets_path / "icon.png" icon_path = assets_path / "icon.png"
@ -14,7 +14,7 @@ class SurveyWindow(QMainWindow):
# window style # window style
self.setWindowIcon(QIcon(__icon_png__)) self.setWindowIcon(QIcon(__icon_png__))
self.setWindowTitle(self.tr("SURVEY")) self.setWindowTitle(__appname__)
# start by asking the user his language # start by asking the user his language
language_selection = ui.LanguageSelection( language_selection = ui.LanguageSelection(