mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -06:00
Remove indirection in the translation
CURA-6005
This commit is contained in:
parent
ed9a51791b
commit
e36b3e37d1
2 changed files with 9 additions and 27 deletions
|
@ -16,24 +16,6 @@ class Settings:
|
||||||
AUTO_BACKUP_ENABLED_PREFERENCE_KEY = "cura_drive/auto_backup_enabled"
|
AUTO_BACKUP_ENABLED_PREFERENCE_KEY = "cura_drive/auto_backup_enabled"
|
||||||
AUTO_BACKUP_LAST_DATE_PREFERENCE_KEY = "cura_drive/auto_backup_date"
|
AUTO_BACKUP_LAST_DATE_PREFERENCE_KEY = "cura_drive/auto_backup_date"
|
||||||
|
|
||||||
I18N_CATALOG_ID = "cura"
|
I18N_CATALOG = i18nCatalog("cura")
|
||||||
I18N_CATALOG = i18nCatalog(I18N_CATALOG_ID)
|
|
||||||
|
|
||||||
MESSAGE_TITLE = I18N_CATALOG.i18nc("@info:title", "Backups")
|
MESSAGE_TITLE = I18N_CATALOG.i18nc("@info:title", "Backups")
|
||||||
|
|
||||||
# Translatable messages for the entire plugin.
|
|
||||||
translatable_messages = {
|
|
||||||
|
|
||||||
# Menu items.
|
|
||||||
"extension_menu_entry": I18N_CATALOG.i18nc("@item:inmenu", "Manage backups"),
|
|
||||||
|
|
||||||
# Notification messages.
|
|
||||||
"backup_failed": I18N_CATALOG.i18nc("@info:backup_status", "There was an error while creating your backup."),
|
|
||||||
"uploading_backup": I18N_CATALOG.i18nc("@info:backup_status", "Uploading your backup..."),
|
|
||||||
"uploading_backup_success": I18N_CATALOG.i18nc("@info:backup_status", "Your backup has finished uploading."),
|
|
||||||
"uploading_backup_error": I18N_CATALOG.i18nc("@info:backup_status",
|
|
||||||
"There was an error while uploading your backup."),
|
|
||||||
"get_backups_error": I18N_CATALOG.i18nc("@info:backup_status", "There was an error listing your backups."),
|
|
||||||
"backup_restore_error_message": I18N_CATALOG.i18nc("@info:backup_status",
|
|
||||||
"There was an error trying to restore your backup.")
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,14 +8,17 @@ from UM.Logger import Logger
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
|
|
||||||
from .Settings import Settings
|
from .Settings import Settings
|
||||||
|
from UM.i18n import i18nCatalog
|
||||||
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
class UploadBackupJob(Job):
|
class UploadBackupJob(Job):
|
||||||
|
MESSAGE_TITLE = catalog.i18nc("@info:title", "Backups")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This job is responsible for uploading the backup file to cloud storage.
|
This job is responsible for uploading the backup file to cloud storage.
|
||||||
As it can take longer than some other tasks, we schedule this using a Cura Job.
|
As it can take longer than some other tasks, we schedule this using a Cura Job.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, signed_upload_url: str, backup_zip: bytes) -> None:
|
def __init__(self, signed_upload_url: str, backup_zip: bytes) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._signed_upload_url = signed_upload_url
|
self._signed_upload_url = signed_upload_url
|
||||||
|
@ -24,18 +27,15 @@ class UploadBackupJob(Job):
|
||||||
self.backup_upload_error_message = ""
|
self.backup_upload_error_message = ""
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
Message(Settings.translatable_messages["uploading_backup"], title = Settings.MESSAGE_TITLE,
|
Message(catalog.i18nc("@info:backup_status", "Uploading your backup..."), title = self.MESSAGE_TITLE).show()
|
||||||
lifetime = 10).show()
|
|
||||||
|
|
||||||
backup_upload = requests.put(self._signed_upload_url, data = self._backup_zip)
|
backup_upload = requests.put(self._signed_upload_url, data = self._backup_zip)
|
||||||
if backup_upload.status_code not in (200, 201):
|
if backup_upload.status_code not in (200, 201):
|
||||||
self.backup_upload_error_message = backup_upload.text
|
self.backup_upload_error_message = backup_upload.text
|
||||||
Logger.log("w", "Could not upload backup file: %s", backup_upload.text)
|
Logger.log("w", "Could not upload backup file: %s", backup_upload.text)
|
||||||
Message(Settings.translatable_messages["uploading_backup_error"], title = Settings.MESSAGE_TITLE,
|
Message(catalog.i18nc("@info:backup_status", "There was an error while uploading your backup."), title = self.MESSAGE_TITLE).show()
|
||||||
lifetime = 10).show()
|
|
||||||
else:
|
else:
|
||||||
self._upload_success = True
|
self._upload_success = True
|
||||||
Message(Settings.translatable_messages["uploading_backup_success"], title = Settings.MESSAGE_TITLE,
|
Message(catalog.i18nc("@info:backup_status", "Your backup has finished uploading."), title = self.MESSAGE_TITLE).show()
|
||||||
lifetime = 10).show()
|
|
||||||
|
|
||||||
self.finished.emit(self)
|
self.finished.emit(self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue