diff --git a/assets/language/en.ts b/assets/language/en.ts
index 9dcdeb1..da19c4c 100644
--- a/assets/language/en.ts
+++ b/assets/language/en.ts
@@ -1,43 +1,43 @@
-
+
LanguageSelection
-
- SELECT YOUR LANGUAGE
- Select your language
+
+ SELECT YOUR LANGUAGE
+ Select your language
-
- START
- Start
+
+ START
+ Start
-
-
+
+
SurveyEngine
-
- WARNING
- Warning
+
+ WARNING
+ Warning
-
-
+
+
SurveyNavigation
-
- ABANDON
- Abandon
+
+ ABANDON
+ Abandon
-
- SKIP
- Skip
+
+ SKIP
+ Skip
-
- NEXT
- Next
+
+ NEXT
+ Next
-
+
diff --git a/assets/language/es.ts b/assets/language/es.ts
index 22c16fc..107725c 100644
--- a/assets/language/es.ts
+++ b/assets/language/es.ts
@@ -1,43 +1,43 @@
-
+
LanguageSelection
-
- SELECT YOUR LANGUAGE
- Seleccione su idioma
+
+ SELECT YOUR LANGUAGE
+ Seleccione su idioma
-
- START
- Comenzar
+
+ START
+ Comenzar
-
-
+
+
SurveyEngine
-
- WARNING
- Atención
+
+ WARNING
+ Atención
-
-
+
+
SurveyNavigation
-
- ABANDON
- Abandonar
+
+ ABANDON
+ Abandonar
-
- SKIP
- Pasar
+
+ SKIP
+ Pasar
-
- NEXT
- Siguiente
+
+ NEXT
+ Siguiente
-
+
diff --git a/assets/language/fr.ts b/assets/language/fr.ts
index 55d7abb..1643019 100644
--- a/assets/language/fr.ts
+++ b/assets/language/fr.ts
@@ -1,43 +1,43 @@
-
+
LanguageSelection
-
- SELECT YOUR LANGUAGE
- Sélectionner votre langue
+
+ SELECT YOUR LANGUAGE
+ Sélectionner votre langue
-
- START
- Démarrer
+
+ START
+ Démarrer
-
-
+
+
SurveyEngine
-
- WARNING
- Attention
+
+ WARNING
+ Attention
-
-
+
+
SurveyNavigation
-
- ABANDON
- Abandonner
+
+ ABANDON
+ Abandonner
-
- SKIP
- Passer
+
+ SKIP
+ Passer
-
- NEXT
- Suivant
+
+ NEXT
+ Suivant
-
+
diff --git a/source/ui/LanguageSelection.py b/source/ui/LanguageSelection.py
index 7f01e06..6ad59d5 100644
--- a/source/ui/LanguageSelection.py
+++ b/source/ui/LanguageSelection.py
@@ -1,14 +1,15 @@
+import typing
from typing import Callable
-from PyQt6.QtCore import Qt, QLocale, QTranslator
-from PyQt6.QtWidgets import QWidget, QLabel, QVBoxLayout, QComboBox, QApplication, QPushButton
+from PyQt6.QtCore import Qt, QLocale
+from PyQt6.QtWidgets import QWidget, QLabel, QVBoxLayout, QComboBox, QPushButton
-from source import assets_path, translate
+from source import assets_path, translate, ui
class LanguageSelection(QWidget):
- def __init__(self, after: Callable):
- super().__init__()
+ def __init__(self, parent: QWidget, after: Callable):
+ super().__init__(parent=parent)
self.after = after
@@ -49,20 +50,18 @@ class LanguageSelection(QWidget):
# refresh the texts
self.refresh_language()
+ super().show()
+
def refresh_language(self):
language_code = self.select_language.currentData()
- # load the correct translator
- translator = QTranslator()
- translator.load(str(assets_path / f"language/{language_code}.qm"))
+ # load the correct translation in the window
+ window = typing.cast(ui.SurveyWindow, self.window())
+ window.translator.load(str(assets_path / f"language/{language_code}.qm"))
# apply the language on the custom translator
translate.set_language(language_code)
- # install the translator on the application
- application = QApplication.instance()
- application.installTranslator(translator)
-
# refresh the texts
self.retranslate()
diff --git a/source/ui/SurveyWindow.py b/source/ui/SurveyWindow.py
index 97bc379..b11e7fa 100644
--- a/source/ui/SurveyWindow.py
+++ b/source/ui/SurveyWindow.py
@@ -1,7 +1,8 @@
from pathlib import Path
+from PyQt6.QtCore import QTranslator
from PyQt6.QtGui import QIcon
-from PyQt6.QtWidgets import QMainWindow
+from PyQt6.QtWidgets import QMainWindow, QApplication
from source import ui, assets_path, __icon_png__, __appname__
@@ -12,16 +13,20 @@ class SurveyWindow(QMainWindow):
def __init__(self, survey_path: Path | str):
super().__init__()
+ self.translator = QTranslator()
+ QApplication.instance().installTranslator(self.translator)
+
# window style
self.setWindowIcon(QIcon(__icon_png__))
self.setWindowTitle(__appname__)
# start by asking the user his language
- language_selection = ui.LanguageSelection(
+ self.language_selection = ui.LanguageSelection(
+ parent=self,
# after the language is selected, start the survey
after=lambda: self.setCentralWidget(ui.SurveyEngine.from_file(survey_path))
)
- self.setCentralWidget(language_selection)
+ self.setCentralWidget(self.language_selection)
def quit(self):
# quit the application by closing and deleting the window