Fix blank_before_percent (#19397)

* Fix blank_before_percent

* types n stuff
This commit is contained in:
karwosts 2024-01-14 12:23:42 -08:00 committed by GitHub
parent 7c389a6cf0
commit 5aa5ce8b5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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":

View File

@ -3,7 +3,7 @@ import { blankBeforePercent } from "./blank_before_percent";
export const blankBeforeUnit = (
unit: string,
localeOptions?: FrontendLocaleData
localeOptions: FrontendLocaleData | undefined
): string => {
if (unit === "°") {
return "";

View File

@ -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";

View File

@ -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`
<div class="container">

View File

@ -261,7 +261,7 @@ export class HaStateControlClimateTemperature extends LitElement {
this.hass.locale,
formatOptions
);
return html`${formatted}${blankBeforeUnit(unit)}${unit}`;
return html`${formatted}${blankBeforeUnit(unit, this.hass.locale)}${unit}`;
}
private _renderCurrent(temperature: number, style: "normal" | "big") {