diff --git a/hassio/src/backups/hassio-backups.ts b/hassio/src/backups/hassio-backups.ts index 80282aa7d6..943e6e6c64 100644 --- a/hassio/src/backups/hassio-backups.ts +++ b/hassio/src/backups/hassio-backups.ts @@ -360,11 +360,9 @@ export class HassioBackups extends LitElement { if (this.supervisor!.info.state !== "running") { showAlertDialog(this, { title: this.supervisor!.localize("backup.could_not_create"), - text: this.supervisor!.localize( - "backup.create_blocked_not_running", - "state", - this.supervisor!.info.state - ), + text: this.supervisor!.localize("backup.create_blocked_not_running", { + state: this.supervisor!.info.state, + }), }); return; } diff --git a/hassio/src/dialogs/backup/dialog-hassio-backup.ts b/hassio/src/dialogs/backup/dialog-hassio-backup.ts index fbf1edc46f..c66de088f7 100644 --- a/hassio/src/dialogs/backup/dialog-hassio-backup.ts +++ b/hassio/src/dialogs/backup/dialog-hassio-backup.ts @@ -31,6 +31,7 @@ import { fileDownload } from "../../../../src/util/file_download"; import "../../components/supervisor-backup-content"; import type { SupervisorBackupContent } from "../../components/supervisor-backup-content"; import { HassioBackupDialogParams } from "./show-dialog-hassio-backup"; +import { BackupOrRestoreKey } from "../../util/translations"; @customElement("dialog-hassio-backup") class HassioBackupDialog @@ -64,6 +65,13 @@ class HassioBackupDialog fireEvent(this, "dialog-closed", { dialog: this.localName }); } + private _localize(key: BackupOrRestoreKey) { + return ( + this._dialogParams!.supervisor?.localize(`backup.${key}`) || + this._dialogParams!.localize!(`ui.panel.page-onboarding.restore.${key}`) + ); + } + protected render() { if (!this._dialogParams || !this._backup) { return nothing; @@ -79,7 +87,7 @@ class HassioBackupDialog ${this._backup.name} ${this._restoringBackup - ? html` ` - : html` - `} + ? html`` + : html` + + + `} ${this._error ? html`${this._error}` - : ""} + : nothing} - Restore + ${this._localize("restore")} - ${!this._dialogParams.onboarding + ${!this._dialogParams.onboarding && this._dialogParams.supervisor ? html` ${this._dialogParams.supervisor?.localize( + >${this._dialogParams.supervisor.localize( "backup.download_backup" )} ${this._dialogParams.supervisor?.localize( + >${this._dialogParams.supervisor.localize( "backup.delete_backup_title" )} ` - : ""} + : nothing} `; } @@ -183,21 +195,22 @@ class HassioBackupDialog } private async _partialRestoreClicked(backupDetails) { - if ( - this._dialogParams?.supervisor !== undefined && - this._dialogParams?.supervisor.info.state !== "running" - ) { + const supervisor = this._dialogParams?.supervisor; + if (supervisor !== undefined && supervisor.info.state !== "running") { await showAlertDialog(this, { - title: "Could not restore backup", - text: `Restoring a backup is not possible right now because the system is in ${this._dialogParams?.supervisor.info.state} state.`, + title: supervisor.localize("backup.could_not_restore"), + text: supervisor.localize("backup.restore_blocked_not_running", { + state: supervisor.info.state, + }), }); return; } if ( !(await showConfirmationDialog(this, { - title: "Are you sure you want to restore this partial backup?", - confirmText: "restore", - dismissText: "cancel", + title: this._localize("confirm_restore_partial_backup_title"), + text: this._localize("confirm_restore_partial_backup_text"), + confirmText: this._localize("restore"), + dismissText: this._localize("cancel"), })) ) { return; @@ -230,22 +243,22 @@ class HassioBackupDialog } private async _fullRestoreClicked(backupDetails) { - if ( - this._dialogParams?.supervisor !== undefined && - this._dialogParams?.supervisor.info.state !== "running" - ) { + const supervisor = this._dialogParams?.supervisor; + if (supervisor !== undefined && supervisor.info.state !== "running") { await showAlertDialog(this, { - title: "Could not restore backup", - text: `Restoring a backup is not possible right now because the system is in ${this._dialogParams?.supervisor.info.state} state.`, + title: supervisor.localize("backup.could_not_restore"), + text: supervisor.localize("backup.restore_blocked_not_running", { + state: supervisor.info.state, + }), }); return; } if ( !(await showConfirmationDialog(this, { - title: - "Are you sure you want to wipe your system and restore this backup?", - confirmText: "restore", - dismissText: "cancel", + title: this._localize("confirm_restore_full_backup_title"), + text: this._localize("confirm_restore_full_backup_text"), + confirmText: this._localize("restore"), + dismissText: this._localize("cancel"), })) ) { return; @@ -279,11 +292,15 @@ class HassioBackupDialog } private async _deleteClicked() { + const supervisor = this._dialogParams?.supervisor; + if (!supervisor) return; + if ( !(await showConfirmationDialog(this, { - title: "Are you sure you want to delete this backup?", - confirmText: "delete", - dismissText: "cancel", + title: supervisor!.localize("backup.confirm_delete_title"), + text: supervisor!.localize("backup.confirm_delete_text"), + confirmText: supervisor!.localize("backup.delete"), + dismissText: supervisor!.localize("backup.cancel"), })) ) { return; @@ -301,6 +318,9 @@ class HassioBackupDialog } private async _downloadClicked() { + const supervisor = this._dialogParams?.supervisor; + if (!supervisor) return; + let signedPath: { path: string }; try { signedPath = await getSignedPath( @@ -320,10 +340,10 @@ class HassioBackupDialog if (window.location.href.includes("ui.nabu.casa")) { const confirm = await showConfirmationDialog(this, { - title: "Potential slow download", - text: "Downloading backups over the Nabu Casa URL will take some time, it is recomended to use your local URL instead, do you want to continue?", - confirmText: "continue", - dismissText: "cancel", + title: supervisor.localize("backup.remote_download_title"), + text: supervisor.localize("backup.remote_download_text"), + confirmText: supervisor.localize("backup.download"), + dismissText: this._localize("cancel"), }); if (!confirm) { return; diff --git a/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts b/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts index da0bbdbef6..3e1fd79a3d 100644 --- a/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts +++ b/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts @@ -89,8 +89,7 @@ class HassioCreateBackupDialog extends LitElement { ), text: this._dialogParams!.supervisor.localize( "backup.create_blocked_not_running", - "state", - this._dialogParams!.supervisor.info.state + { state: this._dialogParams!.supervisor.info.state } ), }); return; diff --git a/hassio/src/util/translations.ts b/hassio/src/util/translations.ts new file mode 100644 index 0000000000..1a7af29ef3 --- /dev/null +++ b/hassio/src/util/translations.ts @@ -0,0 +1,4 @@ +import type { TranslationDict } from "../../../src/types"; + +export type BackupOrRestoreKey = keyof TranslationDict["supervisor"]["backup"] & + keyof TranslationDict["ui"]["panel"]["page-onboarding"]["restore"]; diff --git a/src/translations/en.json b/src/translations/en.json index 6d66fb31c4..204bc20eca 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -5858,7 +5858,14 @@ "addons": "[%key:supervisor::backup::addons%]", "password_protection": "[%key:supervisor::backup::password_protection%]", "password": "[%key:supervisor::backup::password%]", - "confirm_password": "[%key:supervisor::backup::confirm_password%]" + "confirm_password": "[%key:supervisor::backup::confirm_password%]", + "confirm_restore_partial_backup_title": "[%key:supervisor::backup::confirm_restore_partial_backup_title%]", + "confirm_restore_partial_backup_text": "[%key:supervisor::backup::confirm_restore_partial_backup_text%]", + "confirm_restore_full_backup_title": "[%key:supervisor::backup::confirm_restore_full_backup_title%]", + "confirm_restore_full_backup_text": "[%key:supervisor::backup::confirm_restore_full_backup_text%]", + "restore": "[%key:supervisor::backup::restore%]", + "close": "[%key:ui::common::close%]", + "cancel": "[%key:ui::common::cancel%]" } }, "custom": { @@ -6261,7 +6268,8 @@ "backup": { "search": "[%key:ui::panel::config::backup::picker::search%]", "no_backups": "You don't have any backups yet.", - "create_blocked_not_running": "Creating a backup is not possible right now because the system is in {state} state.", + "create_blocked_not_running": "Creating a backup is not possible right now because the system is in \"{state}\" state.", + "restore_blocked_not_running": "Restoring a backup is not possible right now because the system is in \"{state}\" state.", "delete_selected": "Delete selected backups", "delete_backup_title": "Delete backup", "delete_backup_text": "Do you want to delete {number} {number, plural,\n one {backup}\n other {backups}\n}?", @@ -6269,6 +6277,7 @@ "selected": "{number} selected", "failed_to_delete": "Failed to delete", "could_not_create": "Could not create backup", + "could_not_restore": "Could not restore backup", "upload_backup": "Upload backup", "download_backup": "Download backup", "create_backup": "Create backup", @@ -6289,7 +6298,21 @@ "password_protection": "Password protection", "enter_password": "Please enter a password.", "passwords_not_matching": "The passwords does not match", - "backup_already_running": "A backup or restore is already running, creating a new backup is currently not possible, try again later." + "backup_already_running": "A backup or restore is already running. Creating a new backup is currently not possible, try again later.", + "confirm_restore_partial_backup_title": "Restore partial backup", + "confirm_restore_partial_backup_text": "The backup will be restored. Depending on the size of the backup, this can take up to 45 min.", + "confirm_restore_full_backup_title": "Restore full backup", + "confirm_restore_full_backup_text": "Your entire system will be wiped and the backup will be restored. Depending on the size of the backup, this can take up to 45 min.", + "confirm_delete_title": "Delete backup", + "confirm_delete_text": "This backup will be permanently deleted and cannot be restored later.", + "restore": "Restore", + "close": "[%key:ui::common::close%]", + "cancel": "[%key:ui::common::cancel%]", + "delete": "[%key:ui::common::delete%]", + "download": "Download", + "more_actions": "More actions", + "remote_download_title": "Potentially slow download", + "remote_download_text": "You are accessing Home Assistant via remote access. Downloading backups over the Nabu Casa URL will take some time. If you are at home, cancel this dialog and enter your local URL, such as 'http://homeassistant.local:8123'" }, "dialog": { "network": {