This commit is contained in:
Archer
2025-07-14 19:38:31 +08:00
committed by GitHub
parent f648011ff0
commit 885a419178
2 changed files with 9 additions and 8 deletions

View File

@@ -1,14 +1,14 @@
import { useTranslation as useNextTranslation } from 'next-i18next'; import { useTranslation as useNextTranslation } from 'next-i18next';
import type { I18nNsType } from '../i18n/i18next';
import { I18N_NAMESPACES_MAP } from '../i18n/constants'; import { I18N_NAMESPACES_MAP } from '../i18n/constants';
export function useTranslation(ns?: I18nNsType[0] | I18nNsType) { export function useTranslation() {
const { t: originalT, ...rest } = useNextTranslation(ns); const { t: originalT, ...rest } = useNextTranslation();
const t = (key: string | undefined, ...args: any[]): string => { const t = (key: string | undefined, ...args: any[]): string => {
if (!key) return ''; if (!key) return '';
if (!I18N_NAMESPACES_MAP[key as any]) { const ns = key.split(':')[0];
if (!I18N_NAMESPACES_MAP[ns as any]) {
return key; return key;
} }

View File

@@ -277,11 +277,12 @@ const NodeTemplateList = ({
.map((input) => ({ .map((input) => ({
...input, ...input,
value: defaultValueMap[input.key] ?? input.value ?? input.defaultValue, value: defaultValueMap[input.key] ?? input.value ?? input.defaultValue,
valueDesc: t(input.valueDesc as any), valueDesc: input.valueDesc ? t(input.valueDesc as any) : undefined,
label: t(input.label as any), label: t(input.label as any),
description: t(input.description as any), description: input.description ? t(input.description as any) : undefined,
debugLabel: t(input.debugLabel as any), placeholder: input.placeholder ? t(input.placeholder as any) : undefined,
toolDescription: t(input.toolDescription as any) debugLabel: input.debugLabel ? t(input.debugLabel as any) : undefined,
toolDescription: input.toolDescription ? t(input.toolDescription as any) : undefined
})), })),
outputs: templateNode.outputs outputs: templateNode.outputs
.filter((output) => output.deprecated !== true) .filter((output) => output.deprecated !== true)