From a76159e9a0572fd5e1e9fc845b5921094873c6c0 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Sat, 7 Dec 2024 18:25:40 -0800 Subject: [PATCH] [i18n] Translate node categories (#1842) * [i18n] Translate node categories * nit * Update locales [skip ci] * Fix some translations * Do translate --------- Co-authored-by: github-actions --- .i18nrc.cjs | 4 +++ scripts/collect-i18n.ts | 16 +++++++++--- src/locales/en.json | 56 +++++++++++++++++++++++++++++++++++++++++ src/locales/ja.json | 56 +++++++++++++++++++++++++++++++++++++++++ src/locales/ru.json | 56 +++++++++++++++++++++++++++++++++++++++++ src/locales/zh.json | 56 +++++++++++++++++++++++++++++++++++++++++ src/scripts/app.ts | 6 ++++- 7 files changed, 246 insertions(+), 4 deletions(-) diff --git a/.i18nrc.cjs b/.i18nrc.cjs index df3590444..2e4fde102 100644 --- a/.i18nrc.cjs +++ b/.i18nrc.cjs @@ -8,4 +8,8 @@ module.exports = defineConfig({ entryLocale: 'en', output: 'src/locales', outputLocales: ['zh', 'ru', 'ja'], + reference: `Keep following model names untranslated: + - flux + - photomaker + ` }); diff --git a/scripts/collect-i18n.ts b/scripts/collect-i18n.ts index c77e0b8ac..7dc7486b2 100644 --- a/scripts/collect-i18n.ts +++ b/scripts/collect-i18n.ts @@ -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 => { @@ -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 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 diff --git a/src/locales/en.json b/src/locales/en.json index 5f50d0418..c82e85c49 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1557,5 +1557,61 @@ "WebcamCapture": { "display_name": "Webcam Capture" } + }, + "nodeCategories": { + "sampling": "sampling", + "loaders": "loaders", + "conditioning": "conditioning", + "latent": "latent", + "inpaint": "inpaint", + "batch": "batch", + "image": "image", + "mask": "mask", + "upscaling": "upscaling", + "_for_testing": "_for_testing", + "transform": "transform", + "advanced": "advanced", + "style_model": "style_model", + "controlnet": "controlnet", + "gligen": "gligen", + "deprecated": "deprecated", + "operations": "operations", + "postprocessing": "postprocessing", + "compositing": "compositing", + "model_merging": "model_merging", + "model_patches": "model_patches", + "unet": "unet", + "preprocessors": "preprocessors", + "custom_sampling": "custom_sampling", + "schedulers": "schedulers", + "samplers": "samplers", + "sigmas": "sigmas", + "guiders": "guiders", + "noise": "noise", + "model": "model", + "animation": "animation", + "video_models": "video_models", + "3d_models": "3d_models", + "upscale_diffusion": "upscale_diffusion", + "photomaker": "photomaker", + "stable_cascade": "stable_cascade", + "instructpix2pix": "instructpix2pix", + "model_specific": "model_specific", + "attention_experiments": "attention_experiments", + "audio": "audio", + "sd3": "sd3", + "guidance": "guidance", + "flux": "flux", + "video": "video", + "ltxv": "ltxv", + "hooks": "hooks", + "create": "create", + "scheduling": "scheduling", + "combine": "combine", + "cond single": "cond single", + "cond pair": "cond pair", + "clip": "clip", + "DevTools": "DevTools", + "api": "api" } } \ No newline at end of file diff --git a/src/locales/ja.json b/src/locales/ja.json index 09233c632..70aa3f1f7 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -197,6 +197,62 @@ "noTasksFound": "タスクが見つかりませんでした", "noTasksFoundMessage": "キューにタスクがありません。", "noWorkflowsFound": "ワークフローが見つかりませんでした。", + "nodeCategories": { + "3d_models": "3Dモデル", + "DevTools": "デブツール", + "_for_testing": "_テスト用", + "advanced": "高度な", + "animation": "アニメーション", + "api": "API", + "attention_experiments": "アテンション実験", + "audio": "オーディオ", + "batch": "バッチ", + "clip": "クリップ", + "combine": "結合", + "compositing": "合成", + "cond pair": "条件ペア", + "cond single": "条件単体", + "conditioning": "条件付け", + "controlnet": "コントロールネット", + "create": "作成", + "custom_sampling": "カスタムサンプリング", + "deprecated": "非推奨", + "flux": "flux", + "gligen": "グライジェン", + "guidance": "ガイダンス", + "guiders": "ガイダー", + "hooks": "フック", + "image": "画像", + "inpaint": "インペイント", + "instructpix2pix": "インストラクションピクス2ピクス", + "latent": "潜在", + "loaders": "ローダー", + "ltxv": "LTXV", + "mask": "マスク", + "model": "モデル", + "model_merging": "モデルマージ", + "model_patches": "モデルパッチ", + "model_specific": "モデル特有", + "noise": "ノイズ", + "operations": "操作", + "photomaker": "photomaker", + "postprocessing": "ポストプロセッシング", + "preprocessors": "前処理", + "samplers": "サンプラー", + "sampling": "サンプリング", + "schedulers": "スケジューラー", + "scheduling": "スケジューリング", + "sd3": "SD3", + "sigmas": "シグマ", + "stable_cascade": "安定したカスケード", + "style_model": "スタイルモデル", + "transform": "変換", + "unet": "U-Net", + "upscale_diffusion": "アップスケール拡散", + "upscaling": "アップスケーリング", + "video": "ビデオ", + "video_models": "ビデオモデル" + }, "nodeDefs": { "AddNoise": { "display_name": "ノイズを追加" diff --git a/src/locales/ru.json b/src/locales/ru.json index 20defd9ff..deddf78ca 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -197,6 +197,62 @@ "noTasksFound": "Задачи не найдены", "noTasksFoundMessage": "В очереди нет задач.", "noWorkflowsFound": "Рабочие процессы не найдены.", + "nodeCategories": { + "3d_models": "3d_модели", + "DevTools": "Инструменты_разработчика", + "_for_testing": "_для_тестирования", + "advanced": "расширенный", + "animation": "анимация", + "api": "api", + "attention_experiments": "эксперименты_внимания", + "audio": "аудио", + "batch": "пакет", + "clip": "клип", + "combine": "объединить", + "compositing": "композитинг", + "cond pair": "условие_пара", + "cond single": "условие_одиночное", + "conditioning": "условие", + "controlnet": "контрольная_сеть", + "create": "создать", + "custom_sampling": "пользовательская_выборка", + "deprecated": "устаревший", + "flux": "flux", + "gligen": "глиген", + "guidance": "направление", + "guiders": "направляющие", + "hooks": "хуки", + "image": "изображение", + "inpaint": "восстановление", + "instructpix2pix": "инструктпикс2пикс", + "latent": "латентный", + "loaders": "загрузчики", + "ltxv": "ltxv", + "mask": "маска", + "model": "модель", + "model_merging": "слияние_моделей", + "model_patches": "патчи_моделей", + "model_specific": "специфичная_модель", + "noise": "шум", + "operations": "операции", + "photomaker": "photomaker", + "postprocessing": "постобработка", + "preprocessors": "предобработчики", + "samplers": "семплеры", + "sampling": "выборка", + "schedulers": "планировщики", + "scheduling": "планирование", + "sd3": "sd3", + "sigmas": "сигмы", + "stable_cascade": "стабильная_каскадная", + "style_model": "модель_стиля", + "transform": "преобразование", + "unet": "унет", + "upscale_diffusion": "увеличение_диффузии", + "upscaling": "увеличение", + "video": "видео", + "video_models": "видеомодели" + }, "nodeDefs": { "AddNoise": { "display_name": "Добавить шум" diff --git a/src/locales/zh.json b/src/locales/zh.json index 6a903a81d..b42e94652 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -197,6 +197,62 @@ "noTasksFound": "未找到任务", "noTasksFoundMessage": "队列中没有任务。", "noWorkflowsFound": "未找到工作流", + "nodeCategories": { + "3d_models": "3D模型", + "DevTools": "开发工具", + "_for_testing": "_用于测试", + "advanced": "高级", + "animation": "动画", + "api": "API", + "attention_experiments": "注意力实验", + "audio": "音频", + "batch": "批处理", + "clip": "剪辑", + "combine": "组合", + "compositing": "合成", + "cond pair": "条件对", + "cond single": "条件单个", + "conditioning": "条件处理", + "controlnet": "控制网络", + "create": "创建", + "custom_sampling": "自定义采样", + "deprecated": "已弃用", + "flux": "flux", + "gligen": "生成", + "guidance": "引导", + "guiders": "引导器", + "hooks": "钩子", + "image": "图像", + "inpaint": "修复", + "instructpix2pix": "指令图像到图像", + "latent": "潜在", + "loaders": "加载器", + "ltxv": "LTXV", + "mask": "掩码", + "model": "模型", + "model_merging": "模型合并", + "model_patches": "模型补丁", + "model_specific": "模型特定", + "noise": "噪声", + "operations": "操作", + "photomaker": "photomaker", + "postprocessing": "后处理", + "preprocessors": "预处理器", + "samplers": "采样器", + "sampling": "采样", + "schedulers": "调度器", + "scheduling": "调度", + "sd3": "SD3", + "sigmas": "西格玛", + "stable_cascade": "稳定级联", + "style_model": "风格模型", + "transform": "变换", + "unet": "U-Net", + "upscale_diffusion": "放大扩散", + "upscaling": "放大", + "video": "视频", + "video_models": "视频模型" + }, "nodeDefs": { "AddNoise": { "display_name": "添加噪声" diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 47d8039ac..e986cc5e9 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1833,7 +1833,11 @@ export class ComfyApp { ), description: def.description ? st(`nodeDefs.${name}.description`, def.description) - : undefined + : undefined, + category: def.category + .split('/') + .map((category) => st(`nodeCategories.${category}`, category)) + .join('/') } ]) )