mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Remove string exception for localize keys (#13354)
This commit is contained in:
parent
ede9d8a073
commit
088b3587e0
@ -314,7 +314,8 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _computeStepDescription(step: DataEntryFlowStepForm) {
|
private _computeStepDescription(step: DataEntryFlowStepForm) {
|
||||||
const resourceKey = `ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.description`;
|
const resourceKey =
|
||||||
|
`ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.description` as const;
|
||||||
const args: string[] = [];
|
const args: string[] = [];
|
||||||
const placeholders = step.description_placeholders || {};
|
const placeholders = step.description_placeholders || {};
|
||||||
Object.keys(placeholders).forEach((key) => {
|
Object.keys(placeholders).forEach((key) => {
|
||||||
|
@ -11,7 +11,6 @@ import { getLocalLanguage } from "../../util/common-translation";
|
|||||||
// Fixing component category will require tighter definition of types from backend and/or web socket
|
// Fixing component category will require tighter definition of types from backend and/or web socket
|
||||||
export type LocalizeKeys =
|
export type LocalizeKeys =
|
||||||
| FlattenObjectKeys<Omit<TranslationDict, "supervisor">>
|
| FlattenObjectKeys<Omit<TranslationDict, "supervisor">>
|
||||||
| `${string}`
|
|
||||||
| `panel.${string}`
|
| `panel.${string}`
|
||||||
| `state.${string}`
|
| `state.${string}`
|
||||||
| `state_attributes.${string}`
|
| `state_attributes.${string}`
|
||||||
|
@ -21,16 +21,16 @@ export const getDefaultPanel = (hass: HomeAssistant): PanelInfo =>
|
|||||||
? hass.panels[hass.defaultPanel]
|
? hass.panels[hass.defaultPanel]
|
||||||
: hass.panels[DEFAULT_PANEL];
|
: hass.panels[DEFAULT_PANEL];
|
||||||
|
|
||||||
export const getPanelNameTranslationKey = (panel: PanelInfo): string => {
|
export const getPanelNameTranslationKey = (panel: PanelInfo) => {
|
||||||
if (panel.url_path === "lovelace") {
|
if (panel.url_path === "lovelace") {
|
||||||
return "panel.states";
|
return "panel.states" as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel.url_path === "profile") {
|
if (panel.url_path === "profile") {
|
||||||
return "panel.profile";
|
return "panel.profile" as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `panel.${panel.title}`;
|
return `panel.${panel.title}` as const;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPanelTitle = (hass: HomeAssistant): string | undefined => {
|
export const getPanelTitle = (hass: HomeAssistant): string | undefined => {
|
||||||
|
@ -550,7 +550,7 @@ export class QuickBar extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _generateServerControlCommands(): CommandItem[] {
|
private _generateServerControlCommands(): CommandItem[] {
|
||||||
const serverActions = ["restart", "stop"];
|
const serverActions = ["restart", "stop"] as const;
|
||||||
|
|
||||||
return serverActions.map((action) => {
|
return serverActions.map((action) => {
|
||||||
const categoryKey: CommandItem["categoryKey"] = "server_control";
|
const categoryKey: CommandItem["categoryKey"] = "server_control";
|
||||||
@ -673,6 +673,7 @@ export class QuickBar extends LitElement {
|
|||||||
this.hass.localize(
|
this.hass.localize(
|
||||||
`ui.dialogs.quick-bar.commands.navigation.${name}`
|
`ui.dialogs.quick-bar.commands.navigation.${name}`
|
||||||
)) ||
|
)) ||
|
||||||
|
// @ts-expect-error
|
||||||
(page.translationKey && this.hass.localize(page.translationKey));
|
(page.translationKey && this.hass.localize(page.translationKey));
|
||||||
|
|
||||||
if (caption) {
|
if (caption) {
|
||||||
|
@ -7,9 +7,9 @@ import { HaDeviceAutomationCard } from "./ha-device-automation-card";
|
|||||||
|
|
||||||
@customElement("ha-device-actions-card")
|
@customElement("ha-device-actions-card")
|
||||||
export class HaDeviceActionsCard extends HaDeviceAutomationCard<DeviceAction> {
|
export class HaDeviceActionsCard extends HaDeviceAutomationCard<DeviceAction> {
|
||||||
protected type = "action";
|
readonly type = "action";
|
||||||
|
|
||||||
protected headerKey = "ui.panel.config.devices.automation.actions.caption";
|
readonly headerKey = "ui.panel.config.devices.automation.actions.caption";
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(localizeDeviceAutomationAction);
|
super(localizeDeviceAutomationAction);
|
||||||
|
@ -25,15 +25,15 @@ export abstract class HaDeviceAutomationCard<
|
|||||||
|
|
||||||
@property() public deviceId?: string;
|
@property() public deviceId?: string;
|
||||||
|
|
||||||
@property() public script = false;
|
@property({ type: Boolean }) public script = false;
|
||||||
|
|
||||||
@property() public automations: T[] = [];
|
@property({ attribute: false }) public automations: T[] = [];
|
||||||
|
|
||||||
@state() public _showSecondary = false;
|
@state() public _showSecondary = false;
|
||||||
|
|
||||||
protected headerKey = "";
|
abstract headerKey: Parameters<typeof this.hass.localize>[0];
|
||||||
|
|
||||||
protected type = "";
|
abstract type: "action" | "condition" | "trigger";
|
||||||
|
|
||||||
private _localizeDeviceAutomation: (
|
private _localizeDeviceAutomation: (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
@ -7,9 +7,9 @@ import { HaDeviceAutomationCard } from "./ha-device-automation-card";
|
|||||||
|
|
||||||
@customElement("ha-device-conditions-card")
|
@customElement("ha-device-conditions-card")
|
||||||
export class HaDeviceConditionsCard extends HaDeviceAutomationCard<DeviceCondition> {
|
export class HaDeviceConditionsCard extends HaDeviceAutomationCard<DeviceCondition> {
|
||||||
protected type = "condition";
|
readonly type = "condition";
|
||||||
|
|
||||||
protected headerKey = "ui.panel.config.devices.automation.conditions.caption";
|
readonly headerKey = "ui.panel.config.devices.automation.conditions.caption";
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(localizeDeviceAutomationCondition);
|
super(localizeDeviceAutomationCondition);
|
||||||
|
@ -7,9 +7,9 @@ import { HaDeviceAutomationCard } from "./ha-device-automation-card";
|
|||||||
|
|
||||||
@customElement("ha-device-triggers-card")
|
@customElement("ha-device-triggers-card")
|
||||||
export class HaDeviceTriggersCard extends HaDeviceAutomationCard<DeviceTrigger> {
|
export class HaDeviceTriggersCard extends HaDeviceAutomationCard<DeviceTrigger> {
|
||||||
protected type = "trigger";
|
readonly type = "trigger";
|
||||||
|
|
||||||
protected headerKey = "ui.panel.config.devices.automation.triggers.caption";
|
readonly headerKey = "ui.panel.config.devices.automation.triggers.caption";
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(localizeDeviceAutomationTrigger);
|
super(localizeDeviceAutomationTrigger);
|
||||||
|
@ -31,7 +31,7 @@ interface Tabs {
|
|||||||
|
|
||||||
interface Tab {
|
interface Tab {
|
||||||
component: string;
|
component: string;
|
||||||
translationKey: string;
|
translationKey: Parameters<HomeAssistant["localize"]>[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement("dialog-entity-editor")
|
@customElement("dialog-entity-editor")
|
||||||
|
@ -494,7 +494,7 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
private _renderErrorScreen() {
|
private _renderErrorScreen() {
|
||||||
const item = this._configEntry!;
|
const item = this._configEntry!;
|
||||||
let stateText: [string, ...unknown[]] | undefined;
|
let stateText: Parameters<typeof this.hass.localize> | undefined;
|
||||||
let stateTextExtra: TemplateResult | string | undefined;
|
let stateTextExtra: TemplateResult | string | undefined;
|
||||||
|
|
||||||
if (item.disabled_by) {
|
if (item.disabled_by) {
|
||||||
|
@ -217,8 +217,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
|||||||
slot="item-icon"
|
slot="item-icon"
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.zwave_js.node_config.set_param_" +
|
`ui.panel.config.zwave_js.node_config.set_param_${result.status}`
|
||||||
result.status
|
|
||||||
)}
|
)}
|
||||||
${result.status === "error" && result.error
|
${result.status === "error" && result.error
|
||||||
? html` <br /><em>${result.error}</em> `
|
? html` <br /><em>${result.error}</em> `
|
||||||
|
@ -74,7 +74,7 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
"level",
|
"level",
|
||||||
html`<span class=${item.level.toLowerCase()}
|
html`<span class=${item.level.toLowerCase()}
|
||||||
>${this.hass.localize(
|
>${this.hass.localize(
|
||||||
"ui.panel.config.logs.level." + item.level.toLowerCase()
|
`ui.panel.config.logs.level.${item.level.toLowerCase()}`
|
||||||
)}</span
|
)}</span
|
||||||
>`
|
>`
|
||||||
);
|
);
|
||||||
|
@ -106,8 +106,7 @@ export class SystemLogCard extends LitElement {
|
|||||||
${this._timestamp(item)} –
|
${this._timestamp(item)} –
|
||||||
${html`(<span class=${item.level.toLowerCase()}
|
${html`(<span class=${item.level.toLowerCase()}
|
||||||
>${this.hass.localize(
|
>${this.hass.localize(
|
||||||
"ui.panel.config.logs.level." +
|
`ui.panel.config.logs.level.${item.level.toLowerCase()}`
|
||||||
item.level.toLowerCase()
|
|
||||||
)}</span
|
)}</span
|
||||||
>) `}
|
>) `}
|
||||||
${integrations[idx]
|
${integrations[idx]
|
||||||
|
@ -72,8 +72,7 @@ export const handleAction = async (
|
|||||||
"action",
|
"action",
|
||||||
serviceName ||
|
serviceName ||
|
||||||
hass.localize(
|
hass.localize(
|
||||||
"ui.panel.lovelace.editor.action-editor.actions." +
|
`ui.panel.lovelace.editor.action-editor.actions.${actionConfig.action}`
|
||||||
actionConfig.action
|
|
||||||
) ||
|
) ||
|
||||||
actionConfig.action
|
actionConfig.action
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user