diff --git a/src/vorta/__main__.py b/src/vorta/__main__.py index a1bb1060..edc335f6 100644 --- a/src/vorta/__main__.py +++ b/src/vorta/__main__.py @@ -4,6 +4,7 @@ import sys import peewee from vorta._version import __version__ +from vorta.i18n import trans_late, translate from vorta.config import SETTINGS_DIR from vorta.log import init_logger, logger from vorta.models import init_db @@ -18,12 +19,13 @@ def main(): logger.critical("Uncaught exception, file a report at https://github.com/borgbase/vorta/issues/new", exc_info=(type, value, tb)) full_exception = ''.join(format_exception(type, value, tb)) + title = trans_late('app', 'Fatal Error') + error_message = trans_late('app', 'Uncaught exception, please file a report with this text at\n' + 'https://github.com/borgbase/vorta/issues/new\n') if app: QMessageBox.critical(None, - app.tr("Fatal Error"), - app.tr( - "Uncaught exception, please file a report with this text at\n" - "https://github.com/borgbase/vorta/issues/new\n") + full_exception) + translate('app', title), + translate('app', error_message) + full_exception) else: # Crashed before app startup, cannot translate sys.exit(1) diff --git a/src/vorta/application.py b/src/vorta/application.py index 34228030..50ee40ef 100644 --- a/src/vorta/application.py +++ b/src/vorta/application.py @@ -198,7 +198,7 @@ class VortaApp(QtSingleApplication): msg.setDefaultButton(abortButton) msg.setText(self.tr(f"The repository at {repo_url} might be in use elsewhere.")) msg.setInformativeText(self.tr("Only break the lock if you are certain no other Borg process " - "on any machine is accessing the repository. Abort or break the lock?")) + "on any machine is accessing the repository. Abort or break the lock?")) msg.accepted.connect(lambda: self.break_lock(profile)) self._msg = msg msg.show() diff --git a/src/vorta/borg/borg_thread.py b/src/vorta/borg/borg_thread.py index 6810e058..b6a3cd6c 100644 --- a/src/vorta/borg/borg_thread.py +++ b/src/vorta/borg/borg_thread.py @@ -13,7 +13,7 @@ from PyQt5 import QtCore from PyQt5.QtWidgets import QApplication from subprocess import Popen, PIPE, TimeoutExpired -from vorta.i18n import trans_late +from vorta.i18n import trans_late, translate from vorta.models import EventLogModel, BackupProfileMixin from vorta.utils import borg_compat, pretty_bytes from vorta.keyring.abc import VortaKeyring @@ -51,10 +51,10 @@ class BorgThread(QtCore.QThread, BackupProfileMixin): self.app.backup_cancelled_event.connect(self.cancel) # Declare labels here for translation - self.category_label = {"files": self.tr("Files"), - "original": self.tr("Original"), - "deduplicated": self.tr("Deduplicated"), - "compressed": self.tr("Compressed"), } + self.category_label = {"files": trans_late("BorgThread", "Files"), + "original": trans_late("BorgThread", "Original"), + "deduplicated": trans_late("BorgThread", "Deduplicated"), + "compressed": trans_late("BorgThread", "Compressed"), } cmd[0] = self.prepare_bin() @@ -237,10 +237,10 @@ class BorgThread(QtCore.QThread, BackupProfileMixin): self.app.backup_log_event.emit(f'{parsed["path"]} ({parsed["status"]})', {}) elif parsed['type'] == 'archive_progress': msg = ( - f"{self.category_label['files']}: {parsed['nfiles']}, " - f"{self.category_label['original']}: {pretty_bytes(parsed['original_size'])}, " - f"{self.category_label['deduplicated']}: {pretty_bytes(parsed['deduplicated_size'])}, " - f"{self.category_label['compressed']}: {pretty_bytes(parsed['compressed_size'])}" + f"{translate('BorgThread','Files')}: {parsed['nfiles']}, " + f"{translate('BorgThread','Original')}: {pretty_bytes(parsed['original_size'])}, " + f"{translate('BorgThread','Deduplicated')}: {pretty_bytes(parsed['deduplicated_size'])}, " # noqa: E501 + f"{translate('BorgThread','Compressed')}: {pretty_bytes(parsed['compressed_size'])}" ) self.app.backup_progress_event.emit(msg) except json.decoder.JSONDecodeError: diff --git a/src/vorta/views/profile_add_edit_dialog.py b/src/vorta/views/profile_add_edit_dialog.py index fd4b936a..8ac814c3 100644 --- a/src/vorta/views/profile_add_edit_dialog.py +++ b/src/vorta/views/profile_add_edit_dialog.py @@ -1,5 +1,6 @@ from PyQt5 import uic, QtCore from PyQt5.QtWidgets import QDialogButtonBox +from ..i18n import translate, trans_late from ..utils import get_asset from ..models import BackupProfileModel @@ -8,10 +9,9 @@ AddProfileUI, AddProfileBase = uic.loadUiType(uifile) class AddProfileWindow(AddProfileBase, AddProfileUI): - profile_changed = QtCore.pyqtSignal(str, int) - def __init__(self, parent=None, rename_existing_id=None): + def __init__(self, parent=None): super().__init__(parent) self.setupUi(self) self.edited_profile = None @@ -23,12 +23,8 @@ class AddProfileWindow(AddProfileBase, AddProfileUI): self.buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Save")) self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel")) - if rename_existing_id is not None: - existing_profile = BackupProfileModel.get(id=rename_existing_id) - self.profileNameField.setText(existing_profile.name) - self.existing_id = rename_existing_id - self.modalTitle.setText(self.tr('Rename Profile')) - + self.name_blank = trans_late('AddProfileWindow', 'Please enter a profile name.') + self.name_exists = trans_late('AddProfileWindow', 'A profile with this name already exists.') # Call validate to set inital messages self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.validate()) @@ -49,13 +45,13 @@ class AddProfileWindow(AddProfileBase, AddProfileUI): name = self.profileNameField.text() # A name was entered? if len(name) == 0: - self._set_status(self.tr('Please enter a profile name.')) + self._set_status(translate('AddProfileWindow', self.name_blank)) return False # Profile with this name already exists? exists = BackupProfileModel.select().where(BackupProfileModel.name == name).count() if exists > 0: - self._set_status(self.tr('A profile with this name already exists.')) + self._set_status(translate('AddProfileWindow', self.name_exists)) return False self._set_status(self.tr('')) @@ -63,6 +59,13 @@ class AddProfileWindow(AddProfileBase, AddProfileUI): class EditProfileWindow(AddProfileWindow): + def __init__(self, parent=None, rename_existing_id=None): + super().__init__(parent) + existing_profile = BackupProfileModel.get(id=rename_existing_id) + self.profileNameField.setText(existing_profile.name) + self.existing_id = rename_existing_id + self.modalTitle.setText(self.tr('Rename Profile')) + def save(self): renamed_profile = BackupProfileModel.get(id=self.existing_id) renamed_profile.name = self.profileNameField.text()