[i18n] Translate node categories (#1842)

* [i18n] Translate node categories

* nit

* Update locales [skip ci]

* Fix some translations

* Do translate

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-12-07 18:25:40 -08:00
committed by GitHub
parent a0ff78dbdb
commit a76159e9a0
7 changed files with 246 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import { formatCamelCase, normalizeI18nKey } from '../src/utils/formatUtil'
import type { ComfyCommandImpl } from '../src/stores/commandStore'
import type { FormItem, SettingParams } from '../src/types/settingTypes'
import type { ComfyApi } from '../src/scripts/api'
import type { ComfyNodeDef } from '../src/types/apiTypes'
const localePath = './src/locales/en.json'
const extractMenuCommandLocaleStrings = (): Set<string> => {
@@ -97,10 +98,10 @@ test('collect-i18n', async ({ comfyPage }) => {
)
// Node Definitions
const nodeDefs = await comfyPage.page.evaluate(async () => {
const nodeDefs = (await comfyPage.page.evaluate(async () => {
const api = window['app'].api as ComfyApi
return await api.getNodeDefs()
})
})) as Record<string, ComfyNodeDef>
const allNodeDefsLocale = Object.fromEntries(
Object.values(nodeDefs)
@@ -114,6 +115,14 @@ test('collect-i18n', async ({ comfyPage }) => {
])
)
const allNodeCategoriesLocale = Object.fromEntries(
Object.values(nodeDefs).flatMap((nodeDef) =>
nodeDef.category
.split('/')
.map((category) => [normalizeI18nKey(category), category])
)
)
fs.writeFileSync(
localePath,
JSON.stringify(
@@ -129,7 +138,8 @@ test('collect-i18n', async ({ comfyPage }) => {
},
serverConfigItems: allServerConfigsLocale,
serverConfigCategories: allServerConfigCategoriesLocale,
nodeDefs: allNodeDefsLocale
nodeDefs: allNodeDefsLocale,
nodeCategories: allNodeCategoriesLocale
},
null,
2