mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 01:39:47 +00:00
Translate template categories (#2937)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -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 }))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user