From 13b69bff1b812e682da9a0f50e14abdcef2aab58 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Mon, 4 Jan 2021 20:55:43 +0100 Subject: [PATCH] Translate timestamp-display errors + tiny tweaks (#8086) * Translate timestamp-display errors + tiny tweaks * Adjust translation key --- src/panels/lovelace/components/hui-timestamp-display.ts | 8 ++++++-- src/panels/lovelace/create-element/create-row-element.ts | 2 +- src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts | 2 +- src/translations/en.json | 6 ++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/components/hui-timestamp-display.ts b/src/panels/lovelace/components/hui-timestamp-display.ts index 4aaa8a25eb..20583e94a6 100644 --- a/src/panels/lovelace/components/hui-timestamp-display.ts +++ b/src/panels/lovelace/components/hui-timestamp-display.ts @@ -57,7 +57,9 @@ class HuiTimestampDisplay extends LitElement { } if (isNaN(this.ts.getTime())) { - return html` Invalid date `; + return html`${this.hass.localize( + "ui.panel.lovelace.components.timestamp-display.invalid" + )}`; } const format = this._format; @@ -68,7 +70,9 @@ class HuiTimestampDisplay extends LitElement { if (format in FORMATS) { return html` ${FORMATS[format](this.ts, this.hass.language)} `; } - return html` Invalid format `; + return html`${this.hass.localize( + "ui.panel.lovelace.components.timestamp-display.invalid_format" + )}`; } protected updated(changedProperties: PropertyValues): void { diff --git a/src/panels/lovelace/create-element/create-row-element.ts b/src/panels/lovelace/create-element/create-row-element.ts index f697b89adf..b7e54b81b1 100644 --- a/src/panels/lovelace/create-element/create-row-element.ts +++ b/src/panels/lovelace/create-element/create-row-element.ts @@ -71,7 +71,7 @@ const DOMAIN_TO_ELEMENT_TYPE = { switch: "toggle", vacuum: "toggle", // Temporary. Once climate is rewritten, - // water heater should get it's own row. + // water heater should get its own row. water_heater: "climate", input_datetime: "input-datetime", weather: "weather", diff --git a/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts b/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts index 52c644788d..68a736caa7 100644 --- a/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts @@ -25,7 +25,7 @@ import { handleAction } from "../common/handle-action"; import { UNAVAILABLE_STATES } from "../../../data/entity"; interface SensorEntityConfig extends EntitiesCardEntityConfig { - format?: "relative" | "date" | "time" | "datetime"; + format?: "relative" | "total" | "date" | "time" | "datetime"; } @customElement("hui-sensor-entity-row") diff --git a/src/translations/en.json b/src/translations/en.json index 3dab7355de..9411c14584 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2834,6 +2834,12 @@ "changed_toast": { "message": "The Lovelace UI configuration for this dashboard was updated. Refresh to see changes?" }, + "components": { + "timestamp-display": { + "invalid": "Invalid timestamp", + "invalid_format": "Invalid display format" + } + }, "reload_lovelace": "Reload UI" }, "mailbox": {