[API Node] Add localizations for template workflow descriptions (#3769)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Christian Byrne
2025-05-05 12:53:02 -07:00
committed by GitHub
parent ea605887fa
commit c24472aeac
12 changed files with 811 additions and 38 deletions

View File

@@ -57,19 +57,63 @@ export const useWorkflowTemplatesStore = defineStore(
return category
})
/**
* Add localization fields to a template.
*/
const addLocalizedFieldsToTemplate = (
template: TemplateInfo,
categoryTitle: string
) => ({
...template,
localizedTitle: st(
`templateWorkflows.template.${normalizeI18nKey(categoryTitle)}.${normalizeI18nKey(template.name)}`,
template.title ?? template.name
),
localizedDescription: st(
`templateWorkflows.templateDescription.${normalizeI18nKey(categoryTitle)}.${normalizeI18nKey(template.name)}`,
template.description
)
})
/**
* Add localization fields to all templates in a list of templates.
*/
const localizeTemplateList = (
templates: TemplateInfo[],
categoryTitle: string
) =>
templates.map((template) =>
addLocalizedFieldsToTemplate(template, categoryTitle)
)
/**
* Add localization fields to a template category and all its constituent templates.
*/
const localizeTemplateCategory = (templateCategory: WorkflowTemplates) => ({
...templateCategory,
localizedTitle: st(
`templateWorkflows.category.${normalizeI18nKey(templateCategory.title)}`,
templateCategory.title ?? templateCategory.moduleName
),
templates: localizeTemplateList(
templateCategory.templates,
templateCategory.title
)
})
const groupedTemplates = computed<TemplateGroup[]>(() => {
const allTemplates = [
...sortCategoryTemplates(coreTemplates.value).map((template) => ({
...template,
title: st(
`templateWorkflows.category.${normalizeI18nKey(template.title)}`,
template.title ?? template.moduleName
)
})),
...sortCategoryTemplates(coreTemplates.value).map(
localizeTemplateCategory
),
...Object.entries(customTemplates.value).map(
([moduleName, templates]) => ({
moduleName,
title: moduleName,
localizedTitle: st(
`templateWorkflows.category.${normalizeI18nKey(moduleName)}`,
moduleName
),
templates: templates.map((name) => ({
name,
mediaType: 'image',