Skip to content
Snippets Groups Projects
Commit d676999f authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] fix Qt standardButtons translation

run gen_translations.py after this commit
parent 207513ba
No related branches found
No related tags found
1 merge request!7750.50.0
......@@ -64,4 +64,9 @@ def build_resources():
prepare_qm()
# add Qt standardButtons qm file
# This file must be copied from Qt libs in the res/i18n/qm folder of the project
qtbase_filename = "qtbase_fr.qm"
if os.path.exists(os.path.join(qm, qtbase_filename)):
qm_shortnames.append(qtbase_filename)
build_resources()
......@@ -5,7 +5,7 @@ import socket
import sakia.i18n_rc
import async_timeout
import aiohttp
from PyQt5.QtCore import QObject, pyqtSignal, QTranslator, QCoreApplication, QLocale, Qt
from PyQt5.QtCore import QObject, pyqtSignal, QTranslator, QCoreApplication, QLocale, Qt, QFile
from . import __version__
from .options import SakiaOptions
from sakia.data.connectors import BmaConnector
......@@ -89,6 +89,7 @@ class Application(QObject):
_logger = attr.ib(default=attr.Factory(lambda: logging.getLogger("sakia")))
available_version = attr.ib(init=False)
_translator = attr.ib(init=False)
_qt_translator = attr.ib(init=False)
def __attrs_post_init__(self):
super().__init__()
......@@ -224,13 +225,26 @@ class Application(QObject):
self._translator = QTranslator(self.qapp)
if locale == "en":
QCoreApplication.installTranslator(self._translator)
elif self._translator.load(":/i18n/{0}".format(locale)):
else:
# load chosen language
filepath = ":/i18n/{0}".format(locale)
if not QFile.exists(filepath):
self._logger.debug("File not found: {0}".format(filepath))
self._translator.load(filepath)
if QCoreApplication.installTranslator(self._translator):
self._logger.debug("Loaded i18n/{0}".format(locale))
self._logger.debug("Loaded {0}".format(filepath))
else:
self._logger.debug("Couldn't load translation")
else:
self._logger.debug("Couldn't load i18n/{0}".format(locale))
self._logger.debug("Couldn't load {0}".format(filepath))
# load standardButtons Qt translation
filepath = ":/i18n/qtbase_{0}".format(locale)
if not QFile.exists(filepath):
self._logger.debug("File not found: {0}".format(filepath))
self._qt_translator = QTranslator(self.qapp)
self._qt_translator.load(filepath)
if QCoreApplication.installTranslator(self._qt_translator):
self._logger.debug("Loaded {0}".format(filepath))
else:
self._logger.debug("Couldn't load {0}".format(filepath))
def start_coroutines(self):
self.network_service.start_coroutines()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment