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"?>
<!DOCTYPE TS>
<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>
<name>SurveyEngine</name>
<message>
@ -27,12 +40,4 @@
<translation>Next</translation>
</message>
</context>
<context>
<name>SurveyWindow</name>
<message>
<location filename="../../source/ui/SurveyWindow.py" line="17"/>
<source>SURVEY</source>
<translation>Survey</translation>
</message>
</context>
</TS>

Binary file not shown.

View file

@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<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>
<name>SurveyEngine</name>
<message>
@ -27,12 +40,4 @@
<translation>Siguiente</translation>
</message>
</context>
<context>
<name>SurveyWindow</name>
<message>
<location filename="../../source/ui/SurveyWindow.py" line="17"/>
<source>SURVEY</source>
<translation>Encuesta</translation>
</message>
</context>
</TS>

Binary file not shown.

View file

@ -1,12 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<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>
<name>SurveyEngine</name>
<message>
<location filename="../../source/ui/SurveyEngine.py" line="177"/>
<source>WARNING</source>
<translation>Avertissement</translation>
<translation>Attention</translation>
</message>
</context>
<context>
@ -27,12 +40,4 @@
<translation>Suivant</translation>
</message>
</context>
<context>
<name>SurveyWindow</name>
<message>
<location filename="../../source/ui/SurveyWindow.py" line="17"/>
<source>SURVEY</source>
<translation>Sondage</translation>
</message>
</context>
</TS>

View file

@ -5,6 +5,7 @@ from typing import Optional
import nextcord
import requests
from PyQt6.QtCore import pyqtSignal
from PyQt6.QtWidgets import QApplication
result_path = Path("./results/")
@ -59,6 +60,7 @@ def upload_discord(
except Exception as exc:
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:
raise exc

View file

@ -19,7 +19,6 @@ class LanguageSelection(QWidget):
# title
self.title = QLabel()
self._layout.addWidget(self.title)
self.title.setText("Select your language.")
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
# language selection
@ -40,13 +39,17 @@ class LanguageSelection(QWidget):
if language == language_default:
self.select_language.setCurrentIndex(i)
self.select_language.currentIndexChanged.connect(self.refresh_language) # NOQA: connect exist
# start button
self.button_start = QPushButton()
self._layout.addWidget(self.button_start)
self.button_start.setText("Start")
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()
# load the correct translator
@ -60,6 +63,14 @@ class LanguageSelection(QWidget):
application = QApplication.instance()
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
self.after()

View file

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

View file

@ -3,7 +3,7 @@ from pathlib import Path
from PyQt6.QtGui import QIcon
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"
@ -14,7 +14,7 @@ class SurveyWindow(QMainWindow):
# window style
self.setWindowIcon(QIcon(__icon_png__))
self.setWindowTitle(self.tr("SURVEY"))
self.setWindowTitle(__appname__)
# start by asking the user his language
language_selection = ui.LanguageSelection(