fixed some translation issues
This commit is contained in:
parent
e7d43371bb
commit
30dd5410f0
5 changed files with 91 additions and 87 deletions
|
@ -1,43 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en">
|
||||
<context>
|
||||
<context>
|
||||
<name>LanguageSelection</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/LanguageSelection.py" line="70"/>
|
||||
<location filename="..\..\source\ui\LanguageSelection.py" line="69" />
|
||||
<source>SELECT YOUR LANGUAGE</source>
|
||||
<translation>Select your language</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/LanguageSelection.py" line="71"/>
|
||||
<location filename="..\..\source\ui\LanguageSelection.py" line="70" />
|
||||
<source>START</source>
|
||||
<translation>Start</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
</context>
|
||||
<context>
|
||||
<name>SurveyEngine</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyEngine.py" line="177"/>
|
||||
<location filename="..\..\source\ui\SurveyEngine.py" line="177" />
|
||||
<source>WARNING</source>
|
||||
<translation>Warning</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
</context>
|
||||
<context>
|
||||
<name>SurveyNavigation</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="19"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="19" />
|
||||
<source>ABANDON</source>
|
||||
<translation>Abandon</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="29"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="29" />
|
||||
<source>SKIP</source>
|
||||
<translation>Skip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="38"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="38" />
|
||||
<source>NEXT</source>
|
||||
<translation>Next</translation>
|
||||
</message>
|
||||
</context>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="es">
|
||||
<context>
|
||||
<context>
|
||||
<name>LanguageSelection</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/LanguageSelection.py" line="70"/>
|
||||
<location filename="..\..\source\ui\LanguageSelection.py" line="69" />
|
||||
<source>SELECT YOUR LANGUAGE</source>
|
||||
<translation>Seleccione su idioma</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/LanguageSelection.py" line="71"/>
|
||||
<location filename="..\..\source\ui\LanguageSelection.py" line="70" />
|
||||
<source>START</source>
|
||||
<translation>Comenzar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
</context>
|
||||
<context>
|
||||
<name>SurveyEngine</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyEngine.py" line="177"/>
|
||||
<location filename="..\..\source\ui\SurveyEngine.py" line="177" />
|
||||
<source>WARNING</source>
|
||||
<translation>Atención</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
</context>
|
||||
<context>
|
||||
<name>SurveyNavigation</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="19"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="19" />
|
||||
<source>ABANDON</source>
|
||||
<translation>Abandonar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="29"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="29" />
|
||||
<source>SKIP</source>
|
||||
<translation>Pasar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="38"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="38" />
|
||||
<source>NEXT</source>
|
||||
<translation>Siguiente</translation>
|
||||
</message>
|
||||
</context>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="fr_FR">
|
||||
<context>
|
||||
<context>
|
||||
<name>LanguageSelection</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/LanguageSelection.py" line="70"/>
|
||||
<location filename="..\..\source\ui\LanguageSelection.py" line="69" />
|
||||
<source>SELECT YOUR LANGUAGE</source>
|
||||
<translation>Sélectionner votre langue</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/LanguageSelection.py" line="71"/>
|
||||
<location filename="..\..\source\ui\LanguageSelection.py" line="70" />
|
||||
<source>START</source>
|
||||
<translation>Démarrer</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
</context>
|
||||
<context>
|
||||
<name>SurveyEngine</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyEngine.py" line="177"/>
|
||||
<location filename="..\..\source\ui\SurveyEngine.py" line="177" />
|
||||
<source>WARNING</source>
|
||||
<translation>Attention</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
</context>
|
||||
<context>
|
||||
<name>SurveyNavigation</name>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="19"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="19" />
|
||||
<source>ABANDON</source>
|
||||
<translation>Abandonner</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="29"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="29" />
|
||||
<source>SKIP</source>
|
||||
<translation>Passer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../source/ui/SurveyNavigation.py" line="38"/>
|
||||
<location filename="..\..\source\ui\SurveyNavigation.py" line="38" />
|
||||
<source>NEXT</source>
|
||||
<translation>Suivant</translation>
|
||||
</message>
|
||||
</context>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue