From 035057b1851695e7b974d4197a164b56170f551e Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Thu, 17 Oct 2019 23:28:12 +0200 Subject: [PATCH] Made thermostat history graph localizable (#4004) * Made thermostat history graph localizable * Changed string concatenation with white spaces from .join() to template literal * Used variables in translations instead of template literals * Update src/translations/en.json Removed unnecessary space in heating value Co-Authored-By: Bram Kragten --- src/components/state-history-chart-line.js | 52 +++++++++++++++++++--- src/translations/en.json | 7 +++ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/components/state-history-chart-line.js b/src/components/state-history-chart-line.js index f94507c2df..6100e4022c 100644 --- a/src/components/state-history-chart-line.js +++ b/src/components/state-history-chart-line.js @@ -181,23 +181,63 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) { state.attributes.target_temp_low ); - addColumn(name + " current temperature", true); + addColumn( + `${this.hass.localize( + "ui.card.climate.current_temperature", + "name", + name + )}`, + true + ); if (hasHeat) { - addColumn(name + " heating", true, true); + addColumn( + `${this.hass.localize("ui.card.climate.heating", "name", name)}`, + true, + true + ); // The "heating" series uses steppedArea to shade the area below the current // temperature when the thermostat is calling for heat. } if (hasCool) { - addColumn(name + " cooling", true, true); + addColumn( + `${this.hass.localize("ui.card.climate.cooling", "name", name)}`, + true, + true + ); // The "cooling" series uses steppedArea to shade the area below the current // temperature when the thermostat is calling for heat. } if (hasTargetRange) { - addColumn(name + " target temperature high", true); - addColumn(name + " target temperature low", true); + addColumn( + `${this.hass.localize( + "ui.card.climate.target_temperature_mode", + "name", + name, + "mode", + this.hass.localize("ui.card.climate.high") + )}`, + true + ); + addColumn( + `${this.hass.localize( + "ui.card.climate.target_temperature_mode", + "name", + name, + "mode", + this.hass.localize("ui.card.climate.low") + )}`, + true + ); } else { - addColumn(name + " target temperature", true); + addColumn( + `${this.hass.localize( + "ui.card.climate.target_temperature_entity", + "name", + name + )}`, + true + ); } states.states.forEach((state) => { diff --git a/src/translations/en.json b/src/translations/en.json index c1554d388f..a302af1917 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -402,6 +402,13 @@ "currently": "Currently", "on_off": "On / off", "target_temperature": "Target temperature", + "target_temperature_entity": "{name} target temperature", + "target_temperature_mode": "{name} target temperature {mode}", + "current_temperature": "{name} current temperature", + "heating": "{name} heating", + "cooling": "{name} cooling", + "high": "high", + "low": "low", "target_humidity": "Target humidity", "operation": "Operation", "fan_mode": "Fan mode",