diff --git a/scripts/collect-i18n.ts b/scripts/collect-i18n.ts index 7024ee0b46..4edc25322b 100644 --- a/scripts/collect-i18n.ts +++ b/scripts/collect-i18n.ts @@ -1,7 +1,7 @@ import * as fs from 'fs' import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage' import { CORE_MENU_COMMANDS } from '../src/constants/coreMenuCommands' -import { normalizeI18nKey } from '../src/utils/formatUtil' +import { formatCamelCase, normalizeI18nKey } from '../src/utils/formatUtil' import type { ComfyCommandImpl } from '../src/stores/commandStore' import type { SettingParams } from '../src/types/settingTypes' @@ -45,7 +45,8 @@ test('collect-i18n', async ({ comfyPage }) => { .map((setting) => ({ id: setting.id, name: setting.name, - tooltip: setting.tooltip + tooltip: setting.tooltip, + category: setting.category })) }) @@ -59,13 +60,30 @@ test('collect-i18n', async ({ comfyPage }) => { ]) ) + const allSettingCategoriesLocale = Object.fromEntries( + settings + .flatMap((setting) => { + return (setting.category ?? setting.id.split('.')).slice(0, 2) + }) + .map((category: string) => [ + normalizeI18nKey(category), + formatCamelCase(category) + ]) + ) + fs.writeFileSync( localePath, JSON.stringify( { ...locale, menuLabels: allLabelsLocale, - settingsDialog: allSettingsLocale + settingsDialog: allSettingsLocale, + // Do merge for settingsCategories as there are some manual translations + // for special panels like "About" and "Keybinding". + settingsCategories: { + ...(locale.settingsCategories ?? {}), + ...allSettingCategoriesLocale + } }, null, 2 diff --git a/src/components/dialog/content/SettingDialogContent.vue b/src/components/dialog/content/SettingDialogContent.vue index d770dfb8f4..44243eab8b 100644 --- a/src/components/dialog/content/SettingDialogContent.vue +++ b/src/components/dialog/content/SettingDialogContent.vue @@ -10,7 +10,7 @@ import('./setting/KeybindingPanel.vue') @@ -132,13 +134,20 @@ const settingRoot = computed(() => settingStore.settingTree) const settingCategories = computed( () => settingRoot.value.children ?? [] ) -const categories = computed(() => [ - ...settingCategories.value, - keybindingPanelNode, - ...extensionPanelNodeList.value, - ...serverConfigPanelNodeList.value, - aboutPanelNode -]) +const { t } = useI18n() +const categories = computed(() => + [ + ...settingCategories.value, + keybindingPanelNode, + ...extensionPanelNodeList.value, + ...serverConfigPanelNodeList.value, + aboutPanelNode + ].map((node) => ({ + ...node, + translatedLabel: t(`settingsCategories.${normalizeI18nKey(node.label)}`) + })) +) + const activeCategory = ref(null) const searchResults = ref([]) diff --git a/src/components/dialog/content/setting/SettingGroup.vue b/src/components/dialog/content/setting/SettingGroup.vue index 8f822fd960..b8e0fc3043 100644 --- a/src/components/dialog/content/setting/SettingGroup.vue +++ b/src/components/dialog/content/setting/SettingGroup.vue @@ -1,7 +1,7 @@