mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 23:36:36 +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) {
|
||||
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 placeholders = step.description_placeholders || {};
|
||||
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
|
||||
export type LocalizeKeys =
|
||||
| FlattenObjectKeys<Omit<TranslationDict, "supervisor">>
|
||||
| `${string}`
|
||||
| `panel.${string}`
|
||||
| `state.${string}`
|
||||
| `state_attributes.${string}`
|
||||
|
@ -21,16 +21,16 @@ export const getDefaultPanel = (hass: HomeAssistant): PanelInfo =>
|
||||
? hass.panels[hass.defaultPanel]
|
||||
: hass.panels[DEFAULT_PANEL];
|
||||
|
||||
export const getPanelNameTranslationKey = (panel: PanelInfo): string => {
|
||||
export const getPanelNameTranslationKey = (panel: PanelInfo) => {
|
||||
if (panel.url_path === "lovelace") {
|
||||
return "panel.states";
|
||||
return "panel.states" as const;
|
||||
}
|
||||
|
||||
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 => {
|
||||
|
@ -550,7 +550,7 @@ export class QuickBar extends LitElement {
|
||||
}
|
||||
|
||||
private _generateServerControlCommands(): CommandItem[] {
|
||||
const serverActions = ["restart", "stop"];
|
||||
const serverActions = ["restart", "stop"] as const;
|
||||
|
||||
return serverActions.map((action) => {
|
||||
const categoryKey: CommandItem["categoryKey"] = "server_control";
|
||||
@ -673,6 +673,7 @@ export class QuickBar extends LitElement {
|
||||
this.hass.localize(
|
||||
`ui.dialogs.quick-bar.commands.navigation.${name}`
|
||||
)) ||
|
||||
// @ts-expect-error
|
||||
(page.translationKey && this.hass.localize(page.translationKey));
|
||||
|
||||
if (caption) {
|
||||
|
@ -7,9 +7,9 @@ import { HaDeviceAutomationCard } from "./ha-device-automation-card";
|
||||
|
||||
@customElement("ha-device-actions-card")
|
||||
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() {
|
||||
super(localizeDeviceAutomationAction);
|
||||
|
@ -25,15 +25,15 @@ export abstract class HaDeviceAutomationCard<
|
||||
|
||||
@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;
|
||||
|
||||
protected headerKey = "";
|
||||
abstract headerKey: Parameters<typeof this.hass.localize>[0];
|
||||
|
||||
protected type = "";
|
||||
abstract type: "action" | "condition" | "trigger";
|
||||
|
||||
private _localizeDeviceAutomation: (
|
||||
hass: HomeAssistant,
|
||||
|
@ -7,9 +7,9 @@ import { HaDeviceAutomationCard } from "./ha-device-automation-card";
|
||||
|
||||
@customElement("ha-device-conditions-card")
|
||||
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() {
|
||||
super(localizeDeviceAutomationCondition);
|
||||
|
@ -7,9 +7,9 @@ import { HaDeviceAutomationCard } from "./ha-device-automation-card";
|
||||
|
||||
@customElement("ha-device-triggers-card")
|
||||
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() {
|
||||
super(localizeDeviceAutomationTrigger);
|
||||
|
@ -31,7 +31,7 @@ interface Tabs {
|
||||
|
||||
interface Tab {
|
||||
component: string;
|
||||
translationKey: string;
|
||||
translationKey: Parameters<HomeAssistant["localize"]>[0];
|
||||
}
|
||||
|
||||
@customElement("dialog-entity-editor")
|
||||
|
@ -494,7 +494,7 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) {
|
||||
|
||||
private _renderErrorScreen() {
|
||||
const item = this._configEntry!;
|
||||
let stateText: [string, ...unknown[]] | undefined;
|
||||
let stateText: Parameters<typeof this.hass.localize> | undefined;
|
||||
let stateTextExtra: TemplateResult | string | undefined;
|
||||
|
||||
if (item.disabled_by) {
|
||||
|
@ -217,8 +217,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
slot="item-icon"
|
||||
></ha-svg-icon>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.node_config.set_param_" +
|
||||
result.status
|
||||
`ui.panel.config.zwave_js.node_config.set_param_${result.status}`
|
||||
)}
|
||||
${result.status === "error" && result.error
|
||||
? html` <br /><em>${result.error}</em> `
|
||||
|
@ -74,7 +74,7 @@ class DialogSystemLogDetail extends LitElement {
|
||||
"level",
|
||||
html`<span class=${item.level.toLowerCase()}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.logs.level." + item.level.toLowerCase()
|
||||
`ui.panel.config.logs.level.${item.level.toLowerCase()}`
|
||||
)}</span
|
||||
>`
|
||||
);
|
||||
|
@ -106,8 +106,7 @@ export class SystemLogCard extends LitElement {
|
||||
${this._timestamp(item)} –
|
||||
${html`(<span class=${item.level.toLowerCase()}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.logs.level." +
|
||||
item.level.toLowerCase()
|
||||
`ui.panel.config.logs.level.${item.level.toLowerCase()}`
|
||||
)}</span
|
||||
>) `}
|
||||
${integrations[idx]
|
||||
|
@ -72,8 +72,7 @@ export const handleAction = async (
|
||||
"action",
|
||||
serviceName ||
|
||||
hass.localize(
|
||||
"ui.panel.lovelace.editor.action-editor.actions." +
|
||||
actionConfig.action
|
||||
`ui.panel.lovelace.editor.action-editor.actions.${actionConfig.action}`
|
||||
) ||
|
||||
actionConfig.action
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user