From fb95de1f7302758c6842b4526d414ce4956308e4 Mon Sep 17 00:00:00 2001
From: Simon Lamon <32477463+silamon@users.noreply.github.com>
Date: Thu, 16 Nov 2023 18:16:51 +0100
Subject: [PATCH] Add translations for the developer tools statistic issues
(#18646)
---
.../statistics/developer-tools-statistics.ts | 138 ++++++++++++------
.../dialog-statistics-adjust-sum.ts | 101 +++++++++----
.../dialog-statistics-fix-units-changed.ts | 30 ++--
src/translations/en.json | 50 ++++++-
4 files changed, 230 insertions(+), 89 deletions(-)
diff --git a/src/panels/developer-tools/statistics/developer-tools-statistics.ts b/src/panels/developer-tools/statistics/developer-tools-statistics.ts
index 7eb112a634..375ef0355e 100644
--- a/src/panels/developer-tools/statistics/developer-tools-statistics.ts
+++ b/src/panels/developer-tools/statistics/developer-tools-statistics.ts
@@ -27,6 +27,7 @@ import { HomeAssistant } from "../../../types";
import { showStatisticsAdjustSumDialog } from "./show-dialog-statistics-adjust-sum";
import { showFixStatisticsUnitsChangedDialog } from "./show-dialog-statistics-fix-units-changed";
import { computeRTLDirection } from "../../../common/util/compute_rtl";
+import { documentationUrl } from "../../../util/documentation-url";
const FIX_ISSUES_ORDER = {
no_state: 0,
@@ -266,13 +267,16 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
switch (issue.type) {
case "no_state":
showConfirmationDialog(this, {
- title: "Entity has no state",
- text: html`This entity has no state at the moment, if this is an
- orphaned entity, you may want to remove the long term statistics of
- it from your database.
Do you want to permanently remove
- the long term statistics of ${issue.data.statistic_id} from your
- database?`,
- confirmText: this.hass.localize("ui.common.remove"),
+ title: this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.no_state.title"
+ ),
+ text: html`${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.no_state.info_text_1"
+ )}
${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.no_state.info_text_2",
+ { statistic_id: issue.data.statistic_id }
+ )}`,
+ confirmText: this.hass.localize("ui.common.delete"),
confirm: async () => {
await clearStatistics(this.hass, [issue.data.statistic_id]);
this._validateStatistics();
@@ -281,60 +285,96 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
break;
case "entity_not_recorded":
showAlertDialog(this, {
- title: "Entity not recorded",
- text: html`State changes of this entity are not recorded, therefore,
- we cannot track long term statistics for it.
You
- probably excluded this entity, or have just included some
- entities.
See the
+ title: this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.title"
+ ),
+ text: html`${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_1"
+ )}
${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_2"
+ )}
- recorder documentation
- for more information.`,
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_3_link"
+ )}`,
});
break;
case "entity_no_longer_recorded":
showAlertDialog(this, {
- title: "Entity no longer recorded",
- text: html`We have generated statistics for this entity in the past,
- but state changes of this entity are no longer recorded, therefore,
- we cannot track long term statistics for it anymore.
You
- probably excluded this entity, or have just included some
- entities.
See the
+ title: this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.title"
+ ),
+ text: html`${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_1"
+ )}
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_2"
+ )}
- recorder documentation
- for more information.`,
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_3_link"
+ )}`,
});
break;
case "unsupported_state_class":
showConfirmationDialog(this, {
- title: "Unsupported state class",
- text: html`The state class of this entity, ${issue.data.state_class}
- is not supported.
Statistics cannot be generated until this
- entity has a supported state class.
If this state class
- was provided by an integration, this is a bug. Please report an
- issue.
If you have set this state class yourself, please
- correct it. The different state classes and when to use which can be
- found in the
-
- developer documentation. If the state class has permanently changed, you may want to
- remove the long term statistics of it from your database.
Do
- you want to permanently remove the long term statistics of
- ${issue.data.statistic_id} from your database?`,
- confirmText: this.hass.localize("ui.common.remove"),
+ title: this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.title"
+ ),
+ text: html`${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_1",
+ { state_class: issue.data.state_class }
+ )}
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_2"
+ )}
+
No statistics found for this period.
`; + stats = html`+ ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.no_statistics_found" + )} +
`; } else { const data = this._stats5min.length >= 1 ? this._stats5min : this._statsHour; @@ -150,11 +154,8 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
- The unit of this entity changed to
- '${this._params.issue.data.state_unit}' which can't be converted to
- the previously stored unit,
- '${this._params.issue.data.metadata_unit}'.
-
If the historic statistic values have a wrong unit, you can
- update the units of the old values. The values will not be updated.
Otherwise
- you can choose to delete all historic statistic values, and start
- over.
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_1",
+ {
+ current_unit: this._params.issue.data.state_unit,
+ previous_unit: this._params.issue.data.metadata_unit,
+ }
+ )}
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_2"
+ )}
+ ${this.hass.localize(
+ "ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_3"
+ )}