refactor(i18n): use JSON with flattened key and namespace (#30114)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Stephen Zhou
2025-12-29 14:52:32 +08:00
committed by GitHub
parent 09be869f58
commit 6d0e36479b
2552 changed files with 111159 additions and 142972 deletions

View File

@ -79,7 +79,7 @@ const VarItem: FC<Props> = ({
? (
<>
{payload.required && (
<div className="mr-2 text-xs font-normal text-text-tertiary">{t('workflow.nodes.start.required')}</div>
<div className="mr-2 text-xs font-normal text-text-tertiary">{t('nodes.start.required', { ns: 'workflow' })}</div>
)}
<InputVarTypeIcon type={payload.type} className="h-3.5 w-3.5 text-text-tertiary" />
</>

View File

@ -31,21 +31,21 @@ const VarList: FC<Props> = ({
const newList = produce(list, (draft) => {
draft[index] = payload
})
let errorMsgKey = ''
let typeName = ''
let errorMsgKey: 'varKeyError.keyAlreadyExists' | '' = ''
let typeName: 'variableConfig.varName' | 'variableConfig.labelName' | '' = ''
if (hasDuplicateStr(newList.map(item => item.variable))) {
errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
typeName = 'appDebug.variableConfig.varName'
errorMsgKey = 'varKeyError.keyAlreadyExists'
typeName = 'variableConfig.varName'
}
else if (hasDuplicateStr(newList.map(item => item.label as string))) {
errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
typeName = 'appDebug.variableConfig.labelName'
errorMsgKey = 'varKeyError.keyAlreadyExists'
typeName = 'variableConfig.labelName'
}
if (errorMsgKey) {
if (errorMsgKey && typeName) {
Toast.notify({
type: 'error',
message: t(errorMsgKey as any, { key: t(typeName as any) as string }) as string,
message: t(errorMsgKey, { ns: 'appDebug', key: t(typeName, { ns: 'appDebug' }) }),
})
return false
}
@ -83,7 +83,7 @@ const VarList: FC<Props> = ({
if (list.length === 0) {
return (
<div className="flex h-[42px] items-center justify-center rounded-md bg-components-panel-bg text-xs font-normal leading-[18px] text-text-tertiary">
{t('workflow.nodes.start.noVarTip')}
{t('nodes.start.noVarTip', { ns: 'workflow' })}
</div>
)
}

View File

@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
import InputVarTypeIcon from '../_base/components/input-var-type-icon'
const i18nPrefix = 'workflow.nodes.start'
const i18nPrefix = 'nodes.start'
const Node: FC<NodeProps<StartNodeType>> = ({
data,
@ -28,7 +28,7 @@ const Node: FC<NodeProps<StartNodeType>> = ({
</div>
<div className="ml-1 flex items-center space-x-1">
{variable.required && <span className="system-2xs-regular-uppercase text-text-tertiary">{t(`${i18nPrefix}.required`)}</span>}
{variable.required && <span className="system-2xs-regular-uppercase text-text-tertiary">{t(`${i18nPrefix}.required`, { ns: 'workflow' })}</span>}
<InputVarTypeIcon type={variable.type} className="h-3 w-3 text-text-tertiary" />
</div>
</div>

View File

@ -12,7 +12,7 @@ import VarItem from './components/var-item'
import VarList from './components/var-list'
import useConfig from './use-config'
const i18nPrefix = 'workflow.nodes.start'
const i18nPrefix = 'nodes.start'
const Panel: FC<NodePanelProps<StartNodeType>> = ({
id,
@ -44,7 +44,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
<div className="mt-2">
<div className="space-y-4 px-4 pb-2">
<Field
title={t(`${i18nPrefix}.inputField`)}
title={t(`${i18nPrefix}.inputField`, { ns: 'workflow' })}
operations={
!readOnly ? <AddButton onClick={showAddVarModal} /> : undefined
}

View File

@ -85,21 +85,21 @@ const useConfig = (id: string, payload: StartNodeType) => {
draft.variables.push(payload)
})
const newList = newInputs.variables
let errorMsgKey = ''
let typeName = ''
let errorMsgKey: 'varKeyError.keyAlreadyExists' | '' = ''
let typeName: 'variableConfig.varName' | 'variableConfig.labelName' | '' = ''
if (hasDuplicateStr(newList.map(item => item.variable))) {
errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
typeName = 'appDebug.variableConfig.varName'
errorMsgKey = 'varKeyError.keyAlreadyExists'
typeName = 'variableConfig.varName'
}
else if (hasDuplicateStr(newList.map(item => item.label as string))) {
errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
typeName = 'appDebug.variableConfig.labelName'
errorMsgKey = 'varKeyError.keyAlreadyExists'
typeName = 'variableConfig.labelName'
}
if (errorMsgKey) {
if (errorMsgKey && typeName) {
Toast.notify({
type: 'error',
message: t(errorMsgKey as any, { key: t(typeName as any) as string }) as string,
message: t(errorMsgKey, { ns: 'appDebug', key: t(typeName, { ns: 'appDebug' }) }),
})
return false
}

View File

@ -51,7 +51,7 @@ const useSingleRunFormParams = ({
forms.push(
{
label: t('workflow.nodes.llm.singleRun.variable')!,
label: t('nodes.llm.singleRun.variable', { ns: 'workflow' })!,
inputs,
values: runInputData,
onChange: setRunInputData,