Skip to content

Commit

Permalink
Fix blank_before_percent (#19397)
Browse files Browse the repository at this point in the history
* Fix blank_before_percent

* types n stuff
  • Loading branch information
karwosts authored Jan 14, 2024
1 parent 7c389a6 commit 5aa5ce8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/entity/compute_state_display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/common/translations/blank_before_percent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion src/common/translations/blank_before_unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { blankBeforePercent } from "./blank_before_percent";

export const blankBeforeUnit = (
unit: string,
localeOptions?: FrontendLocaleData
localeOptions: FrontendLocaleData | undefined
): string => {
if (unit === "°") {
return "";
Expand Down
4 changes: 3 additions & 1 deletion src/components/ha-big-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 3 additions & 1 deletion src/components/ha-control-number-buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 5aa5ce8

Please sign in to comment.