Translate template categories (#2937)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Christian Byrne
2025-03-09 10:47:49 -07:00
committed by GitHub
parent 83f9240587
commit 72994621a6
8 changed files with 105 additions and 4 deletions

View File

@@ -1,23 +1,34 @@
import { groupBy } from 'lodash'
import { defineStore } from 'pinia'
import { computed, ref, shallowRef } from 'vue'
import { useI18n } from 'vue-i18n'
import { api } from '@/scripts/api'
import type {
TemplateGroup,
WorkflowTemplates
} from '@/types/workflowTemplateTypes'
import { normalizeI18nKey } from '@/utils/formatUtil'
export const useWorkflowTemplatesStore = defineStore(
'workflowTemplates',
() => {
const { t } = useI18n()
const customTemplates = shallowRef<{ [moduleName: string]: string[] }>({})
const coreTemplates = shallowRef<WorkflowTemplates[]>([])
const isLoaded = ref(false)
const groupedTemplates = computed<TemplateGroup[]>(() => {
const allTemplates = [
...coreTemplates.value,
...coreTemplates.value.map((template) => ({
...template,
title: t(
`templateWorkflows.category.${normalizeI18nKey(template.title)}`,
{
defaultValue: template.title
}
)
})),
...Object.entries(customTemplates.value).map(
([moduleName, templates]) => ({
moduleName,
@@ -33,8 +44,14 @@ export const useWorkflowTemplatesStore = defineStore(
]
return Object.entries(
groupBy(allTemplates, (t) =>
t.moduleName === 'default' ? 'ComfyUI Examples' : 'Custom Nodes'
groupBy(allTemplates, (template) =>
template.moduleName === 'default'
? t('templateWorkflows.category.ComfyUI Examples', {
defaultValue: 'ComfyUI Examples'
})
: t('templateWorkflows.category.Custom Nodes', {
defaultValue: 'Custom Nodes'
})
)
).map(([label, modules]) => ({ label, modules }))
})