@@ -92,7 +93,6 @@ class StateInfo extends LitElement {
state-badge {
float: left;
}
-
:host([rtl]) state-badge {
float: right;
}
diff --git a/src/components/ha-relative-time.ts b/src/components/ha-relative-time.ts
index 3c9f991f5e..b7c950942d 100644
--- a/src/components/ha-relative-time.ts
+++ b/src/components/ha-relative-time.ts
@@ -1,6 +1,7 @@
import { PropertyValues, ReactiveElement } from "lit";
import { customElement, property } from "lit/decorators";
import { relativeTime } from "../common/datetime/relative_time";
+import { capitalizeFirstLetter } from "../common/string/capitalize-first-letter";
import type { HomeAssistant } from "../types";
@customElement("ha-relative-time")
@@ -9,6 +10,8 @@ class HaRelativeTime extends ReactiveElement {
@property({ attribute: false }) public datetime?: string | Date;
+ @property({ type: Boolean }) public capitalize = false;
+
private _interval?: number;
public disconnectedCallback(): void {
@@ -55,7 +58,10 @@ class HaRelativeTime extends ReactiveElement {
if (!this.datetime) {
this.innerHTML = this.hass.localize("ui.components.relative_time.never");
} else {
- this.innerHTML = relativeTime(new Date(this.datetime), this.hass.locale);
+ const relTime = relativeTime(new Date(this.datetime), this.hass.locale);
+ this.innerHTML = this.capitalize
+ ? capitalizeFirstLetter(relTime)
+ : relTime;
}
}
}
diff --git a/src/dialogs/more-info/controls/more-info-automation.ts b/src/dialogs/more-info/controls/more-info-automation.ts
index 0584b977ed..fab8cfb54b 100644
--- a/src/dialogs/more-info/controls/more-info-automation.ts
+++ b/src/dialogs/more-info/controls/more-info-automation.ts
@@ -25,6 +25,7 @@ class MoreInfoAutomation extends LitElement {
diff --git a/src/dialogs/more-info/controls/more-info-script.ts b/src/dialogs/more-info/controls/more-info-script.ts
index 39ce62214e..2f42f1b6e7 100644
--- a/src/dialogs/more-info/controls/more-info-script.ts
+++ b/src/dialogs/more-info/controls/more-info-script.ts
@@ -28,6 +28,7 @@ class MoreInfoScript extends LitElement {
`
: this.hass.localize("ui.components.relative_time.never")}
diff --git a/src/dialogs/more-info/controls/more-info-sun.ts b/src/dialogs/more-info/controls/more-info-sun.ts
index 254693e681..728dcfcf72 100644
--- a/src/dialogs/more-info/controls/more-info-sun.ts
+++ b/src/dialogs/more-info/controls/more-info-sun.ts
@@ -73,9 +73,6 @@ class MoreInfoSun extends LitElement {
display: inline-block;
white-space: nowrap;
}
- ha-relative-time::first-letter {
- text-transform: lowercase;
- }
hr {
border-color: var(--divider-color);
border-bottom: none;
diff --git a/src/dialogs/notifications/persistent-notification-item.ts b/src/dialogs/notifications/persistent-notification-item.ts
index 93abe761ad..1bd0c408d8 100644
--- a/src/dialogs/notifications/persistent-notification-item.ts
+++ b/src/dialogs/notifications/persistent-notification-item.ts
@@ -31,6 +31,7 @@ export class HuiPersistentNotificationItem extends LitElement {
${this._computeTooltip(this.hass, this.notification)}
diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-logs.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-logs.ts
index 9edf199887..8df84d6576 100644
--- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-logs.ts
+++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-logs.ts
@@ -16,6 +16,7 @@ import { haStyle } from "../../../../../resources/styles";
import { HomeAssistant, Route } from "../../../../../types";
import { fileDownload } from "../../../../../util/file_download";
import { configTabs } from "./zwave_js-config-router";
+import { capitalizeFirstLetter } from "../../../../../common/string/capitalize-first-letter";
@customElement("zwave_js-logs")
class ZWaveJSLogs extends SubscribeMixin(LitElement) {
@@ -149,7 +150,7 @@ class ZWaveJSLogs extends SubscribeMixin(LitElement) {
setZWaveJSLogLevel(this.hass!, this.configEntryId, selected);
this._textarea!.value += `${this.hass.localize(
"ui.panel.config.zwave_js.logs.log_level_changed",
- { level: selected.charAt(0).toUpperCase() + selected.slice(1) }
+ { level: capitalizeFirstLetter(selected) }
)}\n`;
}
diff --git a/src/panels/config/tags/ha-config-tags.ts b/src/panels/config/tags/ha-config-tags.ts
index 50b4eeccf3..09d5096d16 100644
--- a/src/panels/config/tags/ha-config-tags.ts
+++ b/src/panels/config/tags/ha-config-tags.ts
@@ -79,6 +79,7 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
? html``
: this.hass.localize("ui.panel.config.tag.never_scanned")}
`
@@ -96,6 +97,7 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
? html``
: this.hass.localize("ui.panel.config.tag.never_scanned")}
`,
diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts
index 7ccae86727..2ac78f9515 100644
--- a/src/panels/logbook/ha-logbook.ts
+++ b/src/panels/logbook/ha-logbook.ts
@@ -210,6 +210,7 @@ class HaLogbook extends LitElement {
${item.domain === "automation" &&
item.context_id! in this.traceContexts
diff --git a/src/panels/lovelace/components/hui-generic-entity-row.ts b/src/panels/lovelace/components/hui-generic-entity-row.ts
index 9c7ca08df3..9a1efd1c2a 100644
--- a/src/panels/lovelace/components/hui-generic-entity-row.ts
+++ b/src/panels/lovelace/components/hui-generic-entity-row.ts
@@ -95,6 +95,7 @@ class HuiGenericEntityRow extends LitElement {
`
: this.config.secondary_info === "last-updated"
@@ -102,6 +103,7 @@ class HuiGenericEntityRow extends LitElement {
`
: this.config.secondary_info === "last-triggered"
@@ -110,6 +112,7 @@ class HuiGenericEntityRow extends LitElement {
`
: this.hass.localize(
diff --git a/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts b/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts
index eb5ba784c0..3a5791e8e3 100644
--- a/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts
+++ b/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts
@@ -103,6 +103,7 @@ export class HuiEntityPickerTable extends LitElement {
`,
};
diff --git a/src/util/hass-attributes-util.ts b/src/util/hass-attributes-util.ts
index 0d08b6ed87..5025aa1766 100644
--- a/src/util/hass-attributes-util.ts
+++ b/src/util/hass-attributes-util.ts
@@ -3,6 +3,7 @@ import { until } from "lit/directives/until";
import checkValidDate from "../common/datetime/check_valid_date";
import { formatDate } from "../common/datetime/format_date";
import { formatDateTimeWithSeconds } from "../common/datetime/format_date_time";
+import { capitalizeFirstLetter } from "../common/string/capitalize-first-letter";
import { isDate } from "../common/string/is_date";
import { isTimestamp } from "../common/string/is_timestamp";
import { HomeAssistant } from "../types";
@@ -159,7 +160,7 @@ export function formatAttributeName(value: string): string {
.replace(/\bip\b/g, "IP")
.replace(/\bmac\b/g, "MAC")
.replace(/\bgps\b/g, "GPS");
- return value.charAt(0).toUpperCase() + value.slice(1);
+ return capitalizeFirstLetter(value);
}
export function formatAttributeValue(