mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 06:47:33 +00:00
[i18n] Split nodeDefs translations to a separate json file (#1878)
* [i18n] Split nodeDefs translations to a separate json file * build locale
This commit is contained in:
@@ -9,6 +9,8 @@ import type { FormItem, SettingParams } from '../src/types/settingTypes'
|
||||
import type { ComfyApi } from '../src/scripts/api'
|
||||
|
||||
const localePath = './src/locales/en/main.json'
|
||||
const nodeDefsPath = './src/locales/en/nodeDefs.json'
|
||||
|
||||
const extractMenuCommandLocaleStrings = (): Set<string> => {
|
||||
const labels = new Set<string>()
|
||||
for (const [category, _] of CORE_MENU_COMMANDS) {
|
||||
@@ -227,7 +229,6 @@ test('collect-i18n', async ({ comfyPage }) => {
|
||||
},
|
||||
serverConfigItems: allServerConfigsLocale,
|
||||
serverConfigCategories: allServerConfigCategoriesLocale,
|
||||
nodeDefs: allNodeDefsLocale,
|
||||
dataTypes: allDataTypesLocale,
|
||||
nodeCategories: allNodeCategoriesLocale
|
||||
},
|
||||
@@ -235,4 +236,6 @@ test('collect-i18n', async ({ comfyPage }) => {
|
||||
2
|
||||
)
|
||||
)
|
||||
|
||||
fs.writeFileSync(nodeDefsPath, JSON.stringify(allNodeDefsLocale, null, 2))
|
||||
})
|
||||
|
||||
22
src/i18n.ts
22
src/i18n.ts
@@ -4,13 +4,25 @@ import zh from './locales/zh/main.json'
|
||||
import ru from './locales/ru/main.json'
|
||||
import ja from './locales/ja/main.json'
|
||||
import ko from './locales/ko/main.json'
|
||||
import enNodes from './locales/en/nodeDefs.json'
|
||||
import zhNodes from './locales/zh/nodeDefs.json'
|
||||
import ruNodes from './locales/ru/nodeDefs.json'
|
||||
import jaNodes from './locales/ja/nodeDefs.json'
|
||||
import koNodes from './locales/ko/nodeDefs.json'
|
||||
|
||||
function buildLocale(main: typeof en, nodes: typeof enNodes) {
|
||||
return {
|
||||
...main,
|
||||
nodeDefs: nodes
|
||||
}
|
||||
}
|
||||
|
||||
const messages: Record<string, typeof en> = {
|
||||
en,
|
||||
zh,
|
||||
ru,
|
||||
ja,
|
||||
ko
|
||||
en: buildLocale(en, enNodes),
|
||||
zh: buildLocale(zh, zhNodes),
|
||||
ru: buildLocale(ru, ruNodes),
|
||||
ja: buildLocale(ja, jaNodes),
|
||||
ko: buildLocale(ko, koNodes)
|
||||
}
|
||||
|
||||
export const i18n = createI18n({
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1201
src/locales/en/nodeDefs.json
Normal file
1201
src/locales/en/nodeDefs.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1201
src/locales/ja/nodeDefs.json
Normal file
1201
src/locales/ja/nodeDefs.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1201
src/locales/ko/nodeDefs.json
Normal file
1201
src/locales/ko/nodeDefs.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1201
src/locales/ru/nodeDefs.json
Normal file
1201
src/locales/ru/nodeDefs.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1201
src/locales/zh/nodeDefs.json
Normal file
1201
src/locales/zh/nodeDefs.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user