From 8178afe08202fed9ccff38b2b2dd23f8ff3dc5e7 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Sun, 30 Dec 2018 13:36:30 +0100 Subject: Use explicit context for translation in python part --- qml/mageiawelcome.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'qml') diff --git a/qml/mageiawelcome.py b/qml/mageiawelcome.py index 48e8eb4..9ace3ec 100644 --- a/qml/mageiawelcome.py +++ b/qml/mageiawelcome.py @@ -3,7 +3,7 @@ from PyQt5.QtGui import QGuiApplication, QIcon from PyQt5.QtQuick import QQuickView from PyQt5.QtCore import QUrl, QLocale, QTranslator, QLibraryInfo, QVariant, QAbstractListModel, \ - QModelIndex, Qt, QObject, pyqtSlot + QModelIndex, Qt, QObject, pyqtSlot, QCoreApplication from PyQt5.QtNetwork import QNetworkConfigurationManager, QNetworkConfiguration import sys import os @@ -13,6 +13,8 @@ import pwd # Workaround for opengl lib selection from OpenGL import GL +translate = QCoreApplication.translate + class ConfList(QAbstractListModel): NameRole = Qt.UserRole + 1 def __init__(self, parent=None): @@ -55,16 +57,16 @@ class ConfList(QAbstractListModel): netconfs += ", " + conf.name() self.configuration = [ - {'name': self.tr("Congratulations!
You have completed the installation of {}").format(release)}, - {'name': self.tr("You are using linux kernel: {}").format(kernel)}, - {'name': self.tr("Your system architecture is: {}").format(arch)}, - {'name': self.tr("You are now using the Desktop: {}").format(desktop)}, - {'name': self.tr("Your user id is: {}").format(os.getuid())}, + {'name': translate('ConfList',"Congratulations!
You have completed the installation of {}").format(release)}, + {'name': translate('ConfList',"You are using linux kernel: {}").format(kernel)}, + {'name': translate('ConfList',"Your system architecture is: {}").format(arch)}, + {'name': translate('ConfList',"You are now using the Desktop: {}").format(desktop)}, + {'name': translate('ConfList',"Your user id is: {}").format(os.getuid())}, ] if net.isOnline(): - self.configuration.append({'name': self.tr("You are connected to a network through {}").format(netconfs)}) + self.configuration.append({'name': translate('ConfList',"You are connected to a network through {}").format(netconfs)}) else: - self.configuration.append({'name': self.tr("You have no network connection")}) + self.configuration.append({'name': translate('ConfList',"You have no network connection")}) def data(self, index, role=Qt.DisplayRole): @@ -147,7 +149,7 @@ if __name__ == '__main__': app.installTranslator(appTranslator) view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - view.setTitle(app.tr("Welcome to Mageia")) + view.setTitle(app.translate('app',"Welcome to Mageia")) app.setWindowIcon(QIcon("icons/32x32/apps/mageiawelcome.png")) cb = Callbrowser() la = Launcher() -- cgit v1.2.1