Fix hassio logs translations (#22693)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Wendelin 2024-11-06 13:33:45 +01:00 committed by GitHub
parent ed3096157c
commit 26e914290d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 92 additions and 43 deletions

View File

@ -38,12 +38,13 @@ class HassioAddonLogDashboard extends LitElement {
@value-changed=${this._filterChanged}
.hass=${this.hass}
.filter=${this._filter}
.label=${this.hass.localize("ui.panel.config.logs.search")}
.label=${this.supervisor.localize("ui.panel.config.logs.search")}
></search-input>
</div>
<div class="content">
<error-log-card
.hass=${this.hass}
.localizeFunc=${this.supervisor.localize}
.header=${this.addon.name}
.provider=${this.addon.slug}
show

View File

@ -64,6 +64,7 @@ import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { debounce } from "../../../common/util/debounce";
import { showDownloadLogsDialog } from "./show-dialog-download-logs";
import type { HaMenu } from "../../../components/ha-menu";
import type { LocalizeFunc } from "../../../common/translations/localize";
const NUMBER_OF_LINES = 100;
@ -71,6 +72,8 @@ const NUMBER_OF_LINES = 100;
class ErrorLogCard extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public localizeFunc?: LocalizeFunc<any>;
@property() public filter = "";
@property() public header?: string;
@ -131,6 +134,7 @@ class ErrorLogCard extends LitElement {
@state() private _logsFileLink;
protected render(): TemplateResult {
const localize = this.localizeFunc || this.hass.localize;
return html`
<div class="error-log-intro">
${this._error
@ -139,8 +143,7 @@ class ErrorLogCard extends LitElement {
<ha-card outlined class=${classMap({ hidden: this.show === false })}>
<div class="header">
<h1 class="card-header">
${this.header ||
this.hass.localize("ui.panel.config.logs.show_full_logs")}
${this.header || localize("ui.panel.config.logs.show_full_logs")}
</h1>
<div class="action-buttons">
${this._streamSupported &&
@ -148,17 +151,16 @@ class ErrorLogCard extends LitElement {
this._showBootsSelect
? html`
<ha-assist-chip
.title=${this.hass.localize(
.title=${localize(
"ui.panel.config.logs.haos_boots_title"
)}
.label=${this._boot === 0
? this.hass.localize("ui.panel.config.logs.current")
? localize("ui.panel.config.logs.current")
: this._boot === -1
? this.hass.localize("ui.panel.config.logs.previous")
: this.hass.localize(
"ui.panel.config.logs.startups_ago",
{ boot: this._boot * -1 }
)}
? localize("ui.panel.config.logs.previous")
: localize("ui.panel.config.logs.startups_ago", {
boot: this._boot * -1,
})}
id="boots-anchor"
@click=${this._toggleBootsMenu}
>
@ -180,14 +182,10 @@ class ErrorLogCard extends LitElement {
.selected=${boot === this._boot}
>
${boot === 0
? this.hass.localize(
"ui.panel.config.logs.current"
)
? localize("ui.panel.config.logs.current")
: boot === -1
? this.hass.localize(
"ui.panel.config.logs.previous"
)
: this.hass.localize(
? localize("ui.panel.config.logs.previous")
: localize(
"ui.panel.config.logs.startups_ago",
{ boot: boot * -1 }
)}
@ -207,9 +205,7 @@ class ErrorLogCard extends LitElement {
<ha-icon-button
.path=${mdiDownload}
@click=${this._downloadLogs}
.label=${this.hass.localize(
"ui.panel.config.logs.download_logs"
)}
.label=${localize("ui.panel.config.logs.download_logs")}
></ha-icon-button>
`
: this._logsFileLink
@ -221,7 +217,7 @@ class ErrorLogCard extends LitElement {
>
<ha-icon-button
.path=${mdiDownload}
.label=${this.hass.localize(
.label=${localize(
"ui.panel.config.logs.download_logs"
)}
></ha-icon-button>
@ -231,7 +227,7 @@ class ErrorLogCard extends LitElement {
<ha-icon-button
.path=${this._wrapLines ? mdiWrapDisabled : mdiWrap}
@click=${this._toggleLineWrap}
.label=${this.hass.localize(
.label=${localize(
`ui.panel.config.logs.${this._wrapLines ? "full_width" : "wrap_lines"}`
)}
></ha-icon-button>
@ -239,7 +235,7 @@ class ErrorLogCard extends LitElement {
? html`<ha-icon-button
.path=${mdiRefresh}
@click=${this._loadLogs}
.label=${this.hass.localize("ui.common.refresh")}
.label=${localize("ui.common.refresh")}
></ha-icon-button>`
: nothing}
${this._streamSupported && Array.isArray(this._boots)
@ -252,7 +248,7 @@ class ErrorLogCard extends LitElement {
slot="graphic"
.path=${mdiFormatListNumbered}
></ha-svg-icon>
${this.hass.localize(
${localize(
`ui.panel.config.logs.${this._showBootsSelect ? "hide" : "show"}_haos_boots`
)}
</ha-list-item>
@ -271,22 +267,17 @@ class ErrorLogCard extends LitElement {
</div>`
: nothing}
${this._loadingState === "loading"
? html`<div>
${this.hass.localize("ui.panel.config.logs.loading_log")}
</div>`
? html`<div>${localize("ui.panel.config.logs.loading_log")}</div>`
: this._loadingState === "empty"
? html`<div>
${this.hass.localize("ui.panel.config.logs.no_errors")}
</div>`
? html`<div>${localize("ui.panel.config.logs.no_errors")}</div>`
: nothing}
${this._loadingState === "loaded" &&
this.filter &&
this._noSearchResults
? html`<div>
${this.hass.localize(
"ui.panel.config.logs.no_issues_search",
{ term: this.filter }
)}
${localize("ui.panel.config.logs.no_issues_search", {
term: this.filter,
})}
</div>`
: nothing}
<ha-ansi-to-html
@ -307,7 +298,7 @@ class ErrorLogCard extends LitElement {
.path=${mdiArrowCollapseDown}
slot="icon"
></ha-svg-icon>
${this.hass.localize("ui.panel.config.logs.scroll_down_button")}
${localize("ui.panel.config.logs.scroll_down_button")}
<ha-svg-icon
.path=${mdiArrowCollapseDown}
slot="trailingIcon"
@ -328,14 +319,12 @@ class ErrorLogCard extends LitElement {
? html`
<ha-button outlined @click=${this._downloadLogs}>
<ha-svg-icon .path=${mdiDownload}></ha-svg-icon>
${this.hass.localize(
"ui.panel.config.logs.download_logs"
)}
${localize("ui.panel.config.logs.download_logs")}
</ha-button>
`
: nothing}
<mwc-button raised @click=${this._showLogs}>
${this.hass.localize("ui.panel.config.logs.load_logs")}
${localize("ui.panel.config.logs.load_logs")}
</mwc-button>
`
: nothing}
@ -572,10 +561,13 @@ class ErrorLogCard extends LitElement {
if (err.name === "AbortError") {
return;
}
this._error = this.hass.localize("ui.panel.config.logs.failed_get_logs", {
provider: this.provider,
error: extractApiErrorMessage(err),
});
this._error = (this.localizeFunc || this.hass.localize)(
"ui.panel.config.logs.failed_get_logs",
{
provider: this.provider,
error: extractApiErrorMessage(err),
}
);
}
}

View File

@ -7855,6 +7855,62 @@
"restore": "[%key:ui::components::data-table::settings::restore%]"
}
}
},
"panel": {
"config": {
"logs": {
"caption": "[%key:ui::panel::config::logs::caption%]",
"description": "[%key:ui::panel::config::logs::description%]",
"details": "[%key:ui::panel::config::logs::details%]",
"search": "[%key:ui::panel::config::logs::search%]",
"failed_get_logs": "[%key:ui::panel::config::logs::failed_get_logs%]",
"no_issues_search": "[%key:ui::panel::config::logs::no_issues_search%]",
"load_logs": "[%key:ui::panel::config::logs::load_logs%]",
"nr_of_lines": "[%key:ui::panel::config::logs::nr_of_lines%]",
"loading_log": "[%key:ui::panel::config::logs::loading_log%]",
"no_errors": "[%key:ui::panel::config::logs::no_errors%]",
"no_issues": "[%key:ui::panel::config::logs::no_issues%]",
"clear": "[%key:ui::panel::config::logs::clear%]",
"refresh": "[%key:ui::panel::config::logs::refresh%]",
"copy": "[%key:ui::panel::config::logs::copy%]",
"log_provider": "[%key:ui::panel::config::logs::log_provider%]",
"multiple_messages": "[%key:ui::panel::config::logs::multiple_messages%]",
"level": {
"critical": "[%key:ui::panel::config::logs::level::critical%]",
"error": "[%key:ui::panel::config::logs::level::error%]",
"warning": "[%key:ui::panel::config::logs::level::warning%]",
"info": "[%key:ui::panel::config::logs::level::info%]",
"debug": "[%key:ui::panel::config::logs::level::debug%]"
},
"custom_integration": "[%key:ui::panel::config::logs::custom_integration%]",
"error_from_custom_integration": "[%key:ui::panel::config::logs::error_from_custom_integration%]",
"show_full_logs": "[%key:ui::panel::config::logs::show_full_logs%]",
"select_number_of_lines": "[%key:ui::panel::config::logs::select_number_of_lines%]",
"lines": "[%key:ui::panel::config::logs::lines%]",
"download_logs": "[%key:ui::panel::config::logs::download_logs%]",
"scroll_down_button": "[%key:ui::panel::config::logs::scroll_down_button%]",
"provider_not_found": "[%key:ui::panel::config::logs::provider_not_found%]",
"provider_not_available": "[%key:ui::panel::config::logs::provider_not_available%]",
"haos_boots_title": "[%key:ui::panel::config::logs::haos_boots_title%]",
"show_haos_boots": "[%key:ui::panel::config::logs::show_haos_boots%]",
"hide_haos_boots": "[%key:ui::panel::config::logs::hide_haos_boots%]",
"full_width": "[%key:ui::panel::config::logs::full_width%]",
"wrap_lines": "[%key:ui::panel::config::logs::wrap_lines%]",
"current": "[%key:ui::panel::config::logs::current%]",
"previous": "[%key:ui::panel::config::logs::previous%]",
"startups_ago": "[%key:ui::panel::config::logs::startups_ago%]",
"detail": {
"logger": "[%key:ui::panel::config::logs::detail::logger%]",
"source": "[%key:ui::panel::config::logs::detail::source%]",
"integration": "[%key:ui::panel::config::integrations::integration%]",
"documentation": "[%key:ui::panel::config::logs::detail::documentation%]",
"issues": "[%key:ui::panel::config::logs::detail::issues%]",
"first_occurred": "[%key:ui::panel::config::logs::detail::first_occurred%]",
"occurrences": "[%key:ui::panel::config::logs::detail::occurrences%]",
"last_logged": "[%key:ui::panel::config::logs::detail::last_logged%]"
}
}
}
}
}
}