mirror of https://github.com/borgbase/vorta
Add untranslated strings. By @samuel-w (#902)
This commit is contained in:
parent
f7533b76b7
commit
bd3c479d1e
|
@ -4,6 +4,7 @@ import sys
|
||||||
|
|
||||||
import peewee
|
import peewee
|
||||||
from vorta._version import __version__
|
from vorta._version import __version__
|
||||||
|
from vorta.i18n import trans_late, translate
|
||||||
from vorta.config import SETTINGS_DIR
|
from vorta.config import SETTINGS_DIR
|
||||||
from vorta.log import init_logger, logger
|
from vorta.log import init_logger, logger
|
||||||
from vorta.models import init_db
|
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",
|
logger.critical("Uncaught exception, file a report at https://github.com/borgbase/vorta/issues/new",
|
||||||
exc_info=(type, value, tb))
|
exc_info=(type, value, tb))
|
||||||
full_exception = ''.join(format_exception(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:
|
if app:
|
||||||
QMessageBox.critical(None,
|
QMessageBox.critical(None,
|
||||||
app.tr("Fatal Error"),
|
translate('app', title),
|
||||||
app.tr(
|
translate('app', error_message) + full_exception)
|
||||||
"Uncaught exception, please file a report with this text at\n"
|
|
||||||
"https://github.com/borgbase/vorta/issues/new\n") + full_exception)
|
|
||||||
else:
|
else:
|
||||||
# Crashed before app startup, cannot translate
|
# Crashed before app startup, cannot translate
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -13,7 +13,7 @@ from PyQt5 import QtCore
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from subprocess import Popen, PIPE, TimeoutExpired
|
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.models import EventLogModel, BackupProfileMixin
|
||||||
from vorta.utils import borg_compat, pretty_bytes
|
from vorta.utils import borg_compat, pretty_bytes
|
||||||
from vorta.keyring.abc import VortaKeyring
|
from vorta.keyring.abc import VortaKeyring
|
||||||
|
@ -51,10 +51,10 @@ class BorgThread(QtCore.QThread, BackupProfileMixin):
|
||||||
self.app.backup_cancelled_event.connect(self.cancel)
|
self.app.backup_cancelled_event.connect(self.cancel)
|
||||||
|
|
||||||
# Declare labels here for translation
|
# Declare labels here for translation
|
||||||
self.category_label = {"files": self.tr("Files"),
|
self.category_label = {"files": trans_late("BorgThread", "Files"),
|
||||||
"original": self.tr("Original"),
|
"original": trans_late("BorgThread", "Original"),
|
||||||
"deduplicated": self.tr("Deduplicated"),
|
"deduplicated": trans_late("BorgThread", "Deduplicated"),
|
||||||
"compressed": self.tr("Compressed"), }
|
"compressed": trans_late("BorgThread", "Compressed"), }
|
||||||
|
|
||||||
cmd[0] = self.prepare_bin()
|
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"]})', {})
|
self.app.backup_log_event.emit(f'{parsed["path"]} ({parsed["status"]})', {})
|
||||||
elif parsed['type'] == 'archive_progress':
|
elif parsed['type'] == 'archive_progress':
|
||||||
msg = (
|
msg = (
|
||||||
f"{self.category_label['files']}: {parsed['nfiles']}, "
|
f"{translate('BorgThread','Files')}: {parsed['nfiles']}, "
|
||||||
f"{self.category_label['original']}: {pretty_bytes(parsed['original_size'])}, "
|
f"{translate('BorgThread','Original')}: {pretty_bytes(parsed['original_size'])}, "
|
||||||
f"{self.category_label['deduplicated']}: {pretty_bytes(parsed['deduplicated_size'])}, "
|
f"{translate('BorgThread','Deduplicated')}: {pretty_bytes(parsed['deduplicated_size'])}, " # noqa: E501
|
||||||
f"{self.category_label['compressed']}: {pretty_bytes(parsed['compressed_size'])}"
|
f"{translate('BorgThread','Compressed')}: {pretty_bytes(parsed['compressed_size'])}"
|
||||||
)
|
)
|
||||||
self.app.backup_progress_event.emit(msg)
|
self.app.backup_progress_event.emit(msg)
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from PyQt5 import uic, QtCore
|
from PyQt5 import uic, QtCore
|
||||||
from PyQt5.QtWidgets import QDialogButtonBox
|
from PyQt5.QtWidgets import QDialogButtonBox
|
||||||
|
from ..i18n import translate, trans_late
|
||||||
from ..utils import get_asset
|
from ..utils import get_asset
|
||||||
from ..models import BackupProfileModel
|
from ..models import BackupProfileModel
|
||||||
|
|
||||||
|
@ -8,10 +9,9 @@ AddProfileUI, AddProfileBase = uic.loadUiType(uifile)
|
||||||
|
|
||||||
|
|
||||||
class AddProfileWindow(AddProfileBase, AddProfileUI):
|
class AddProfileWindow(AddProfileBase, AddProfileUI):
|
||||||
|
|
||||||
profile_changed = QtCore.pyqtSignal(str, int)
|
profile_changed = QtCore.pyqtSignal(str, int)
|
||||||
|
|
||||||
def __init__(self, parent=None, rename_existing_id=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.edited_profile = None
|
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.Save).setText(self.tr("Save"))
|
||||||
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
|
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
|
||||||
|
|
||||||
if rename_existing_id is not None:
|
self.name_blank = trans_late('AddProfileWindow', 'Please enter a profile name.')
|
||||||
existing_profile = BackupProfileModel.get(id=rename_existing_id)
|
self.name_exists = trans_late('AddProfileWindow', 'A profile with this name already exists.')
|
||||||
self.profileNameField.setText(existing_profile.name)
|
|
||||||
self.existing_id = rename_existing_id
|
|
||||||
self.modalTitle.setText(self.tr('Rename Profile'))
|
|
||||||
|
|
||||||
# Call validate to set inital messages
|
# Call validate to set inital messages
|
||||||
self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.validate())
|
self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.validate())
|
||||||
|
|
||||||
|
@ -49,13 +45,13 @@ class AddProfileWindow(AddProfileBase, AddProfileUI):
|
||||||
name = self.profileNameField.text()
|
name = self.profileNameField.text()
|
||||||
# A name was entered?
|
# A name was entered?
|
||||||
if len(name) == 0:
|
if len(name) == 0:
|
||||||
self._set_status(self.tr('Please enter a profile name.'))
|
self._set_status(translate('AddProfileWindow', self.name_blank))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Profile with this name already exists?
|
# Profile with this name already exists?
|
||||||
exists = BackupProfileModel.select().where(BackupProfileModel.name == name).count()
|
exists = BackupProfileModel.select().where(BackupProfileModel.name == name).count()
|
||||||
if exists > 0:
|
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
|
return False
|
||||||
|
|
||||||
self._set_status(self.tr(''))
|
self._set_status(self.tr(''))
|
||||||
|
@ -63,6 +59,13 @@ class AddProfileWindow(AddProfileBase, AddProfileUI):
|
||||||
|
|
||||||
|
|
||||||
class EditProfileWindow(AddProfileWindow):
|
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):
|
def save(self):
|
||||||
renamed_profile = BackupProfileModel.get(id=self.existing_id)
|
renamed_profile = BackupProfileModel.get(id=self.existing_id)
|
||||||
renamed_profile.name = self.profileNameField.text()
|
renamed_profile.name = self.profileNameField.text()
|
||||||
|
|
Loading…
Reference in New Issue