mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add translations for restore backup dialogs (#18112)
Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
parent
0489d8922e
commit
e1a71fbfaa
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
<ha-header-bar>
|
||||
<span slot="title">${this._backup.name}</span>
|
||||
<ha-icon-button
|
||||
.label=${this.hass?.localize("ui.common.close") || "Close"}
|
||||
.label=${this._localize("close")}
|
||||
.path=${mdiClose}
|
||||
slot="actionItems"
|
||||
dialogAction="cancel"
|
||||
@ -87,29 +95,31 @@ class HassioBackupDialog
|
||||
</ha-header-bar>
|
||||
</div>
|
||||
${this._restoringBackup
|
||||
? html` <ha-circular-progress active></ha-circular-progress>`
|
||||
: html`<supervisor-backup-content
|
||||
.hass=${this.hass}
|
||||
.supervisor=${this._dialogParams.supervisor}
|
||||
.backup=${this._backup}
|
||||
.onboarding=${this._dialogParams.onboarding || false}
|
||||
.localize=${this._dialogParams.localize}
|
||||
dialogInitialFocus
|
||||
>
|
||||
</supervisor-backup-content>`}
|
||||
? html`<ha-circular-progress active></ha-circular-progress>`
|
||||
: html`
|
||||
<supervisor-backup-content
|
||||
.hass=${this.hass}
|
||||
.supervisor=${this._dialogParams.supervisor}
|
||||
.backup=${this._backup}
|
||||
.onboarding=${this._dialogParams.onboarding || false}
|
||||
.localize=${this._dialogParams.localize}
|
||||
dialogInitialFocus
|
||||
>
|
||||
</supervisor-backup-content>
|
||||
`}
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
: ""}
|
||||
: nothing}
|
||||
|
||||
<mwc-button
|
||||
.disabled=${this._restoringBackup}
|
||||
slot="secondaryAction"
|
||||
@click=${this._restoreClicked}
|
||||
>
|
||||
Restore
|
||||
${this._localize("restore")}
|
||||
</mwc-button>
|
||||
|
||||
${!this._dialogParams.onboarding
|
||||
${!this._dialogParams.onboarding && this._dialogParams.supervisor
|
||||
? html`<ha-button-menu
|
||||
fixed
|
||||
slot="primaryAction"
|
||||
@ -117,22 +127,24 @@ class HassioBackupDialog
|
||||
@closed=${stopPropagation}
|
||||
>
|
||||
<ha-icon-button
|
||||
.label=${this.hass!.localize("ui.common.menu") || "Menu"}
|
||||
.label=${this._dialogParams.supervisor.localize(
|
||||
"backup.more_actions"
|
||||
)}
|
||||
.path=${mdiDotsVertical}
|
||||
slot="trigger"
|
||||
></ha-icon-button>
|
||||
<mwc-list-item
|
||||
>${this._dialogParams.supervisor?.localize(
|
||||
>${this._dialogParams.supervisor.localize(
|
||||
"backup.download_backup"
|
||||
)}</mwc-list-item
|
||||
>
|
||||
<mwc-list-item class="error"
|
||||
>${this._dialogParams.supervisor?.localize(
|
||||
>${this._dialogParams.supervisor.localize(
|
||||
"backup.delete_backup_title"
|
||||
)}</mwc-list-item
|
||||
>
|
||||
</ha-button-menu>`
|
||||
: ""}
|
||||
: nothing}
|
||||
</ha-dialog>
|
||||
`;
|
||||
}
|
||||
@ -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;
|
||||
|
@ -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;
|
||||
|
4
hassio/src/util/translations.ts
Normal file
4
hassio/src/util/translations.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import type { TranslationDict } from "../../../src/types";
|
||||
|
||||
export type BackupOrRestoreKey = keyof TranslationDict["supervisor"]["backup"] &
|
||||
keyof TranslationDict["ui"]["panel"]["page-onboarding"]["restore"];
|
@ -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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user