mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +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'
|
import type { ComfyApi } from '../src/scripts/api'
|
||||||
|
|
||||||
const localePath = './src/locales/en/main.json'
|
const localePath = './src/locales/en/main.json'
|
||||||
|
const nodeDefsPath = './src/locales/en/nodeDefs.json'
|
||||||
|
|
||||||
const extractMenuCommandLocaleStrings = (): Set<string> => {
|
const extractMenuCommandLocaleStrings = (): Set<string> => {
|
||||||
const labels = new Set<string>()
|
const labels = new Set<string>()
|
||||||
for (const [category, _] of CORE_MENU_COMMANDS) {
|
for (const [category, _] of CORE_MENU_COMMANDS) {
|
||||||
@@ -227,7 +229,6 @@ test('collect-i18n', async ({ comfyPage }) => {
|
|||||||
},
|
},
|
||||||
serverConfigItems: allServerConfigsLocale,
|
serverConfigItems: allServerConfigsLocale,
|
||||||
serverConfigCategories: allServerConfigCategoriesLocale,
|
serverConfigCategories: allServerConfigCategoriesLocale,
|
||||||
nodeDefs: allNodeDefsLocale,
|
|
||||||
dataTypes: allDataTypesLocale,
|
dataTypes: allDataTypesLocale,
|
||||||
nodeCategories: allNodeCategoriesLocale
|
nodeCategories: allNodeCategoriesLocale
|
||||||
},
|
},
|
||||||
@@ -235,4 +236,6 @@ test('collect-i18n', async ({ comfyPage }) => {
|
|||||||
2
|
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 ru from './locales/ru/main.json'
|
||||||
import ja from './locales/ja/main.json'
|
import ja from './locales/ja/main.json'
|
||||||
import ko from './locales/ko/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> = {
|
const messages: Record<string, typeof en> = {
|
||||||
en,
|
en: buildLocale(en, enNodes),
|
||||||
zh,
|
zh: buildLocale(zh, zhNodes),
|
||||||
ru,
|
ru: buildLocale(ru, ruNodes),
|
||||||
ja,
|
ja: buildLocale(ja, jaNodes),
|
||||||
ko
|
ko: buildLocale(ko, koNodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const i18n = createI18n({
|
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