mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add support for translation domain in data entry flows (#19900)
This commit is contained in:
parent
a479c6e786
commit
841b9c0917
@ -33,6 +33,7 @@ export interface DataEntryFlowStepForm {
|
|||||||
description_placeholders?: Record<string, string>;
|
description_placeholders?: Record<string, string>;
|
||||||
last_step: boolean | null;
|
last_step: boolean | null;
|
||||||
preview?: string;
|
preview?: string;
|
||||||
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataEntryFlowStepExternal {
|
export interface DataEntryFlowStepExternal {
|
||||||
@ -42,6 +43,7 @@ export interface DataEntryFlowStepExternal {
|
|||||||
step_id: string;
|
step_id: string;
|
||||||
url: string;
|
url: string;
|
||||||
description_placeholders: Record<string, string>;
|
description_placeholders: Record<string, string>;
|
||||||
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataEntryFlowStepCreateEntry {
|
export interface DataEntryFlowStepCreateEntry {
|
||||||
@ -53,6 +55,7 @@ export interface DataEntryFlowStepCreateEntry {
|
|||||||
result?: ConfigEntry;
|
result?: ConfigEntry;
|
||||||
description: string;
|
description: string;
|
||||||
description_placeholders?: Record<string, string>;
|
description_placeholders?: Record<string, string>;
|
||||||
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataEntryFlowStepAbort {
|
export interface DataEntryFlowStepAbort {
|
||||||
@ -61,6 +64,7 @@ export interface DataEntryFlowStepAbort {
|
|||||||
handler: string;
|
handler: string;
|
||||||
reason: string;
|
reason: string;
|
||||||
description_placeholders?: Record<string, string>;
|
description_placeholders?: Record<string, string>;
|
||||||
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataEntryFlowStepProgress {
|
export interface DataEntryFlowStepProgress {
|
||||||
@ -70,6 +74,7 @@ export interface DataEntryFlowStepProgress {
|
|||||||
step_id: string;
|
step_id: string;
|
||||||
progress_action: string;
|
progress_action: string;
|
||||||
description_placeholders?: Record<string, string>;
|
description_placeholders?: Record<string, string>;
|
||||||
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataEntryFlowStepMenu {
|
export interface DataEntryFlowStepMenu {
|
||||||
@ -80,6 +85,7 @@ export interface DataEntryFlowStepMenu {
|
|||||||
/** If array, use value to lookup translations in strings.json */
|
/** If array, use value to lookup translations in strings.json */
|
||||||
menu_options: string[] | Record<string, string>;
|
menu_options: string[] | Record<string, string>;
|
||||||
description_placeholders?: Record<string, string>;
|
description_placeholders?: Record<string, string>;
|
||||||
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DataEntryFlowStep =
|
export type DataEntryFlowStep =
|
||||||
|
@ -44,7 +44,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderAbortDescription(hass, step) {
|
renderAbortDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.abort.${step.reason}`,
|
`component.${step.translation_domain || step.handler}.config.abort.${step.reason}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export const showConfigFlowDialog = (
|
|||||||
renderShowFormStepHeader(hass, step) {
|
renderShowFormStepHeader(hass, step) {
|
||||||
return (
|
return (
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${step.handler}.config.step.${step.step_id}.title`,
|
`component.${step.translation_domain || step.handler}.config.step.${step.step_id}.title`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
) || hass.localize(`component.${step.handler}.title`)
|
) || hass.localize(`component.${step.handler}.title`)
|
||||||
);
|
);
|
||||||
@ -66,7 +66,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderShowFormStepDescription(hass, step) {
|
renderShowFormStepDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.step.${step.step_id}.description`,
|
`component.${step.translation_domain || step.handler}.config.step.${step.step_id}.description`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -84,7 +84,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderShowFormStepFieldHelper(hass, step, field) {
|
renderShowFormStepFieldHelper(hass, step, field) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.step.${step.step_id}.data_description.${field.name}`,
|
`component.${step.translation_domain || step.handler}.config.step.${step.step_id}.data_description.${field.name}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -95,7 +95,7 @@ export const showConfigFlowDialog = (
|
|||||||
renderShowFormStepFieldError(hass, step, error) {
|
renderShowFormStepFieldError(hass, step, error) {
|
||||||
return (
|
return (
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${step.handler}.config.error.${error}`,
|
`component.${step.translation_domain || step.translation_domain || step.handler}.config.error.${error}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
) || error
|
) || error
|
||||||
);
|
);
|
||||||
@ -131,7 +131,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderExternalStepDescription(hass, step) {
|
renderExternalStepDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.${step.step_id}.description`,
|
`component.${step.translation_domain || step.handler}.config.${step.step_id}.description`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderCreateEntryDescription(hass, step) {
|
renderCreateEntryDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.create_entry.${
|
`component.${step.translation_domain || step.handler}.config.create_entry.${
|
||||||
step.description || "default"
|
step.description || "default"
|
||||||
}`,
|
}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
@ -190,7 +190,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderShowFormProgressDescription(hass, step) {
|
renderShowFormProgressDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.progress.${step.progress_action}`,
|
`component.${step.translation_domain || step.handler}.config.progress.${step.progress_action}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -210,7 +210,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderMenuDescription(hass, step) {
|
renderMenuDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${step.handler}.config.step.${step.step_id}.description`,
|
`component.${step.translation_domain || step.handler}.config.step.${step.step_id}.description`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -222,7 +222,7 @@ export const showConfigFlowDialog = (
|
|||||||
|
|
||||||
renderMenuOption(hass, step, option) {
|
renderMenuOption(hass, step, option) {
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`component.${step.handler}.config.step.${step.step_id}.menu_options.${option}`,
|
`component.${step.translation_domain || step.handler}.config.step.${step.step_id}.menu_options.${option}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -53,7 +53,7 @@ export const showOptionsFlowDialog = (
|
|||||||
|
|
||||||
renderAbortDescription(hass, step) {
|
renderAbortDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${configEntry.domain}.options.abort.${step.reason}`,
|
`component.${step.translation_domain || configEntry.domain}.options.abort.${step.reason}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export const showOptionsFlowDialog = (
|
|||||||
renderShowFormStepHeader(hass, step) {
|
renderShowFormStepHeader(hass, step) {
|
||||||
return (
|
return (
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${configEntry.domain}.options.step.${step.step_id}.title`,
|
`component.${step.translation_domain || configEntry.domain}.options.step.${step.step_id}.title`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
) || hass.localize(`ui.dialogs.options_flow.form.header`)
|
) || hass.localize(`ui.dialogs.options_flow.form.header`)
|
||||||
);
|
);
|
||||||
@ -79,7 +79,7 @@ export const showOptionsFlowDialog = (
|
|||||||
|
|
||||||
renderShowFormStepDescription(hass, step) {
|
renderShowFormStepDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${configEntry.domain}.options.step.${step.step_id}.description`,
|
`component.${step.translation_domain || configEntry.domain}.options.step.${step.step_id}.description`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -101,7 +101,7 @@ export const showOptionsFlowDialog = (
|
|||||||
|
|
||||||
renderShowFormStepFieldHelper(hass, step, field) {
|
renderShowFormStepFieldHelper(hass, step, field) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${configEntry.domain}.options.step.${step.step_id}.data_description.${field.name}`,
|
`component.${step.translation_domain || configEntry.domain}.options.step.${step.step_id}.data_description.${field.name}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -112,7 +112,7 @@ export const showOptionsFlowDialog = (
|
|||||||
renderShowFormStepFieldError(hass, step, error) {
|
renderShowFormStepFieldError(hass, step, error) {
|
||||||
return (
|
return (
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${configEntry.domain}.options.error.${error}`,
|
`component.${step.translation_domain || configEntry.domain}.options.error.${error}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
) || error
|
) || error
|
||||||
);
|
);
|
||||||
@ -159,7 +159,7 @@ export const showOptionsFlowDialog = (
|
|||||||
|
|
||||||
renderShowFormProgressDescription(hass, step) {
|
renderShowFormProgressDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${configEntry.domain}.options.progress.${step.progress_action}`,
|
`component.${step.translation_domain || configEntry.domain}.options.progress.${step.progress_action}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -183,7 +183,7 @@ export const showOptionsFlowDialog = (
|
|||||||
|
|
||||||
renderMenuDescription(hass, step) {
|
renderMenuDescription(hass, step) {
|
||||||
const description = hass.localize(
|
const description = hass.localize(
|
||||||
`component.${configEntry.domain}.options.step.${step.step_id}.description`,
|
`component.${step.translation_domain || configEntry.domain}.options.step.${step.step_id}.description`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
return description
|
return description
|
||||||
@ -199,7 +199,7 @@ export const showOptionsFlowDialog = (
|
|||||||
|
|
||||||
renderMenuOption(hass, step, option) {
|
renderMenuOption(hass, step, option) {
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`component.${configEntry.domain}.options.step.${step.step_id}.menu_options.${option}`,
|
`component.${step.translation_domain || configEntry.domain}.options.step.${step.step_id}.menu_options.${option}`,
|
||||||
step.description_placeholders
|
step.description_placeholders
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user