diff --git a/src/common/entity/compute_state_display.ts b/src/common/entity/compute_state_display.ts index 70a41a5893..8410c284e7 100644 --- a/src/common/entity/compute_state_display.ts +++ b/src/common/entity/compute_state_display.ts @@ -113,7 +113,7 @@ export const computeStateDisplayFromEntityAttributes = ( const unit = attributes.unit_of_measurement; if (unit) { - return `${value}${blankBeforeUnit(unit)}${unit}`; + return `${value}${blankBeforeUnit(unit, locale)}${unit}`; } return value; diff --git a/src/common/translations/blank_before_percent.ts b/src/common/translations/blank_before_percent.ts index 49fece6675..4c489c96c8 100644 --- a/src/common/translations/blank_before_percent.ts +++ b/src/common/translations/blank_before_percent.ts @@ -4,7 +4,7 @@ import { FrontendLocaleData } from "../../data/translation"; export const blankBeforePercent = ( localeOptions: FrontendLocaleData ): string => { - switch (localeOptions?.language) { + switch (localeOptions.language) { case "cz": case "de": case "fi": diff --git a/src/common/translations/blank_before_unit.ts b/src/common/translations/blank_before_unit.ts index 34fe8ab2d5..32a430430a 100644 --- a/src/common/translations/blank_before_unit.ts +++ b/src/common/translations/blank_before_unit.ts @@ -3,7 +3,7 @@ import { blankBeforePercent } from "./blank_before_percent"; export const blankBeforeUnit = ( unit: string, - localeOptions?: FrontendLocaleData + localeOptions: FrontendLocaleData | undefined ): string => { if (unit === "°") { return ""; diff --git a/src/components/ha-big-number.ts b/src/components/ha-big-number.ts index 48abfe2327..f9e3d8e62d 100644 --- a/src/components/ha-big-number.ts +++ b/src/components/ha-big-number.ts @@ -32,7 +32,9 @@ export class HaBigNumber extends LitElement { const temperatureDecimal = formatted.replace(integer, ""); const formattedValue = `${this.value}${ - this.unit ? `${blankBeforeUnit(this.unit)}${this.unit}` : "" + this.unit + ? `${blankBeforeUnit(this.unit, this.hass?.locale)}${this.unit}` + : "" }`; const unitBottom = this.unitPosition === "bottom"; diff --git a/src/components/ha-control-number-buttons.ts b/src/components/ha-control-number-buttons.ts index 1311b244b3..61f76e708f 100644 --- a/src/components/ha-control-number-buttons.ts +++ b/src/components/ha-control-number-buttons.ts @@ -136,7 +136,9 @@ export class HaControlNumberButton extends LitElement { this.value != null ? formatNumber(this.value, this.locale, this.formatOptions) : ""; - const unit = this.unit ? `${blankBeforeUnit(this.unit)}${this.unit}` : ""; + const unit = this.unit + ? `${blankBeforeUnit(this.unit, this.locale)}${this.unit}` + : ""; return html`