From da480e9bea9e94bc26639c8a533797d3dd7354da Mon Sep 17 00:00:00 2001 From: Andrey Ponomarenko Date: Wed, 1 Dec 2021 22:48:09 +0300 Subject: [PATCH] Fix translations --- Resources/askpass.py | 13 ++++++++++++- Resources/hardware-probe.py | 6 +++--- Resources/i18n/ru.ts | 22 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Resources/askpass.py b/Resources/askpass.py index f75737f..8440fee 100755 --- a/Resources/askpass.py +++ b/Resources/askpass.py @@ -20,9 +20,20 @@ from PyQt5 import QtWidgets +import tstranslator + +tstr = None +def tr(input): + global tstr + try: + if not tstr: + tstr = tstranslator.TsTranslator(os.path.dirname(__file__) + "/i18n", "") + return tstr.tr(input) + except: + return input app = QtWidgets.QApplication([]) -password, ok = QtWidgets.QInputDialog.getText(None, "sudo", "Password", QtWidgets.QLineEdit.Password) +password, ok = QtWidgets.QInputDialog.getText(None, "sudo", tr("Password"), QtWidgets.QLineEdit.Password) if ok: print(password) app.exit(0) \ No newline at end of file diff --git a/Resources/hardware-probe.py b/Resources/hardware-probe.py index e09451f..b798514 100755 --- a/Resources/hardware-probe.py +++ b/Resources/hardware-probe.py @@ -37,7 +37,7 @@ import tempfile import shutil -from PyQt5 import QtWidgets, QtGui, QtCore # pkg install py37-qt5-widgets +from PyQt5 import QtWidgets, QtGui, QtCore from PyQt5.QtWidgets import QTreeView, QFileSystemModel, QVBoxLayout, QPlainTextEdit, QMainWindow # Plenty of TODOs and FIXMEs are sprinkled across this code. @@ -47,7 +47,7 @@ # Translate this application using Qt .ts files without the need for compilation import tstranslator -# FIXME: Do not import translations from outside of the appliction bundle +# FIXME: Do not import translations from outside of the application bundle # which currently is difficult because we have all translations for all applications # in the whole repository in the same .ts files tstr = None @@ -283,7 +283,7 @@ def initializePage(self): def run_probe_locally(self): proc = QtCore.QProcess() - if os.environ.get('HW_PROBE_FLATPAK') or os.environ.get('HW_PROBE_SNAP'): + if os.environ.get('HW_PROBE_FLATPAK') or os.environ.get('HW_PROBE_SNAP') or os.environ.get('NO_SUDO'): command = self.wizard().hw_probe_tool args = ["-all", "-output", self.wizard().hw_probe_output] else: diff --git a/Resources/i18n/ru.ts b/Resources/i18n/ru.ts index 98509af..6aebfb2 100644 --- a/Resources/i18n/ru.ts +++ b/Resources/i18n/ru.ts @@ -89,7 +89,7 @@ This will upload the anonymized hardware probe to the Linux hardware database. The probe will be published publicly under a permanent URL to view the probe. - Переход далее загрузит анонимную пробу оборудования в базу данных оборудования Linux. Проба будет опубликована и доступна по постояноой ссылке для ее просмотра. + Переход далее загрузит анонимную пробу оборудования в базу данных оборудования Linux. Проба будет опубликована и доступна по постоянной ссылке для ее просмотра. Private information (including the username, hostname, IP addresses, MAC addresses, UUIDs and serial numbers) is not uploaded to the database. @@ -119,6 +119,26 @@ Open file Открыть файл + + Password + Пароль + + + Back + Назад + + + Go Back + Назад + + + Next + Продолжить + + + Cancel + Отмена + tstr