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

@ -41,12 +41,12 @@ const AgentLogNav = ({
variant="ghost-accent"
onClick={() => onShowAgentOrToolLog(first)}
>
{t('workflow.nodes.agent.strategy.label')}
{t('nodes.agent.strategy.label', { ns: 'workflow' })}
</Button>
)
: (
<div className="system-xs-medium-uppercase flex items-center px-[5px] text-text-tertiary">
{t('workflow.nodes.agent.strategy.label')}
{t('nodes.agent.strategy.label', { ns: 'workflow' })}
</div>
)
}

View File

@ -25,7 +25,7 @@ const AgentLogTrigger = ({
}}
>
<div className="system-2xs-medium-uppercase flex items-center px-3 pt-2 text-text-tertiary">
{t('workflow.nodes.agent.strategy.label')}
{t('nodes.agent.strategy.label', { ns: 'workflow' })}
</div>
<div className="flex items-center pb-1.5 pl-3 pr-2 pt-1">
{
@ -38,7 +38,7 @@ const AgentLogTrigger = ({
<div
className="system-xs-regular-uppercase flex shrink-0 cursor-pointer items-center px-[1px] text-text-tertiary"
>
{t('runLog.detail')}
{t('detail', { ns: 'runLog' })}
<RiArrowRightLine className="ml-0.5 h-3.5 w-3.5" />
</div>
</div>

View File

@ -47,7 +47,7 @@ const AgentResultPanel = ({
</div>
<RiAlertFill className="mr-1.5 h-4 w-4 text-text-warning-secondary" />
<div className="system-xs-medium text-text-primary">
{t('runLog.circularInvocationTip')}
{t('circularInvocationTip', { ns: 'runLog' })}
</div>
</div>
)

View File

@ -130,7 +130,7 @@ const RunPanel: FC<RunProps> = ({
)}
onClick={() => switchTab('RESULT')}
>
{t('runLog.result')}
{t('result', { ns: 'runLog' })}
</div>
)}
<div
@ -140,7 +140,7 @@ const RunPanel: FC<RunProps> = ({
)}
onClick={() => switchTab('DETAIL')}
>
{t('runLog.detail')}
{t('detail', { ns: 'runLog' })}
</div>
<div
className={cn(
@ -149,7 +149,7 @@ const RunPanel: FC<RunProps> = ({
)}
onClick={() => switchTab('TRACING')}
>
{t('runLog.tracing')}
{t('tracing', { ns: 'runLog' })}
</div>
</div>
{/* panel detail */}

View File

@ -136,11 +136,11 @@ const IterationLogTrigger = ({
>
<Iteration className="h-4 w-4 shrink-0 text-components-button-tertiary-text" />
<div className="system-sm-medium flex-1 text-left text-components-button-tertiary-text">
{t('workflow.nodes.iteration.iteration', { count: displayIterationCount })}
{t('nodes.iteration.iteration', { ns: 'workflow', count: displayIterationCount })}
{errorCount > 0 && (
<>
{t('workflow.nodes.iteration.comma')}
{t('workflow.nodes.iteration.error', { count: errorCount })}
{t('nodes.iteration.comma', { ns: 'workflow' })}
{t('nodes.iteration.error', { ns: 'workflow', count: errorCount })}
</>
)}
</div>

View File

@ -15,7 +15,7 @@ import TracingPanel from '@/app/components/workflow/run/tracing-panel'
import { NodeRunningStatus } from '@/app/components/workflow/types'
import { cn } from '@/utils/classnames'
const i18nPrefix = 'workflow.singleRun'
const i18nPrefix = 'singleRun'
type Props = {
list: NodeTracing[][]
@ -83,7 +83,7 @@ const IterationResultPanel: FC<Props> = ({
}}
>
<RiArrowLeftLine className="mr-1 h-4 w-4" />
<div className="system-sm-medium">{t(`${i18nPrefix}.back`)}</div>
<div className="system-sm-medium">{t(`${i18nPrefix}.back`, { ns: 'workflow' })}</div>
</div>
{/* List */}
<div className="bg-components-panel-bg p-2">
@ -102,7 +102,7 @@ const IterationResultPanel: FC<Props> = ({
<Iteration className="h-3 w-3 text-text-primary-on-surface" />
</div>
<span className="system-sm-semibold-uppercase grow text-text-primary">
{t(`${i18nPrefix}.iteration`)}
{t(`${i18nPrefix}.iteration`, { ns: 'workflow' })}
{' '}
{index + 1}
</span>

View File

@ -96,11 +96,11 @@ const LoopLogTrigger = ({
>
<Loop className="h-4 w-4 shrink-0 text-components-button-tertiary-text" />
<div className="system-sm-medium flex-1 text-left text-components-button-tertiary-text">
{t('workflow.nodes.loop.loop', { count: displayLoopCount })}
{t('nodes.loop.loop', { ns: 'workflow', count: displayLoopCount })}
{errorCount > 0 && (
<>
{t('workflow.nodes.loop.comma')}
{t('workflow.nodes.loop.error', { count: errorCount })}
{t('nodes.loop.comma', { ns: 'workflow' })}
{t('nodes.loop.error', { ns: 'workflow', count: errorCount })}
</>
)}
</div>

View File

@ -17,7 +17,7 @@ import TracingPanel from '@/app/components/workflow/run/tracing-panel'
import { NodeRunningStatus } from '@/app/components/workflow/types'
import { cn } from '@/utils/classnames'
const i18nPrefix = 'workflow.singleRun'
const i18nPrefix = 'singleRun'
type Props = {
list: NodeTracing[][]
@ -89,7 +89,7 @@ const LoopResultPanel: FC<Props> = ({
}}
>
<RiArrowLeftLine className="mr-1 h-4 w-4" />
<div className="system-sm-medium">{t(`${i18nPrefix}.back`)}</div>
<div className="system-sm-medium">{t(`${i18nPrefix}.back`, { ns: 'workflow' })}</div>
</div>
{/* List */}
<div className="bg-components-panel-bg p-2">
@ -108,7 +108,7 @@ const LoopResultPanel: FC<Props> = ({
<Loop className="h-3 w-3 text-text-primary-on-surface" />
</div>
<span className="system-sm-semibold-uppercase grow text-text-primary">
{t(`${i18nPrefix}.loop`)}
{t(`${i18nPrefix}.loop`, { ns: 'workflow' })}
{' '}
{index + 1}
</span>
@ -133,7 +133,7 @@ const LoopResultPanel: FC<Props> = ({
<div className="p-2 pb-0">
<CodeEditor
readOnly
title={<div>{t('workflow.nodes.loop.loopVariables').toLocaleUpperCase()}</div>}
title={<div>{t('nodes.loop.loopVariables', { ns: 'workflow' }).toLocaleUpperCase()}</div>}
language={CodeLanguage.json}
height={112}
value={loopVariableMap[index]}

View File

@ -13,7 +13,7 @@ import { cn } from '@/utils/classnames'
import { ArrowNarrowLeft } from '../../base/icons/src/vender/line/arrows'
import TracingPanel from './tracing-panel'
const i18nPrefix = 'workflow.singleRun'
const i18nPrefix = 'singleRun'
type Props = {
list: NodeTracing[][]
@ -43,7 +43,7 @@ const LoopResultPanel: FC<Props> = ({
<div className={cn(!noWrap && 'shrink-0 ', 'px-4 pt-3')}>
<div className="flex h-8 shrink-0 items-center justify-between">
<div className="system-xl-semibold truncate text-text-primary">
{t(`${i18nPrefix}.testRunLoop` as any) as string}
{t(`${i18nPrefix}.testRunLoop`, { ns: 'workflow' }) }
</div>
<div className="ml-2 shrink-0 cursor-pointer p-1" onClick={onHide}>
<RiCloseLine className="h-4 w-4 text-text-tertiary" />
@ -51,7 +51,7 @@ const LoopResultPanel: FC<Props> = ({
</div>
<div className="flex cursor-pointer items-center space-x-1 py-2 text-text-accent-secondary" onClick={onBack}>
<ArrowNarrowLeft className="h-4 w-4" />
<div className="system-sm-medium">{t(`${i18nPrefix}.back`)}</div>
<div className="system-sm-medium">{t(`${i18nPrefix}.back`, { ns: 'workflow' })}</div>
</div>
</div>
{/* List */}
@ -71,7 +71,7 @@ const LoopResultPanel: FC<Props> = ({
<Loop className="h-3 w-3 text-text-primary-on-surface" />
</div>
<span className="system-sm-semibold-uppercase grow text-text-primary">
{t(`${i18nPrefix}.loop`)}
{t(`${i18nPrefix}.loop`, { ns: 'workflow' })}
{' '}
{index + 1}
</span>

View File

@ -27,10 +27,10 @@ const MetaData: FC<Props> = ({
return (
<div className="relative">
<div className="system-xs-medium-uppercase h-6 py-1 text-text-tertiary">{t('runLog.meta.title')}</div>
<div className="system-xs-medium-uppercase h-6 py-1 text-text-tertiary">{t('meta.title', { ns: 'runLog' })}</div>
<div className="py-1">
<div className="flex">
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('runLog.meta.status')}</div>
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('meta.status', { ns: 'runLog' })}</div>
<div className="system-xs-regular grow px-2 py-1.5 text-text-secondary">
{status === 'running' && (
<div className="my-1 h-2 w-16 rounded-sm bg-text-quaternary" />
@ -53,7 +53,7 @@ const MetaData: FC<Props> = ({
</div>
</div>
<div className="flex">
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('runLog.meta.executor')}</div>
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('meta.executor', { ns: 'runLog' })}</div>
<div className="system-xs-regular grow px-2 py-1.5 text-text-secondary">
{status === 'running' && (
<div className="my-1 h-2 w-[88px] rounded-sm bg-text-quaternary" />
@ -64,18 +64,18 @@ const MetaData: FC<Props> = ({
</div>
</div>
<div className="flex">
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('runLog.meta.startTime')}</div>
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('meta.startTime', { ns: 'runLog' })}</div>
<div className="system-xs-regular grow px-2 py-1.5 text-text-secondary">
{status === 'running' && (
<div className="my-1 h-2 w-[72px] rounded-sm bg-text-quaternary" />
)}
{status !== 'running' && (
<span>{startTime ? formatTime(startTime, t('appLog.dateTimeFormat') as string) : '-'}</span>
<span>{startTime ? formatTime(startTime, t('dateTimeFormat', { ns: 'appLog' }) as string) : '-'}</span>
)}
</div>
</div>
<div className="flex">
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('runLog.meta.time')}</div>
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('meta.time', { ns: 'runLog' })}</div>
<div className="system-xs-regular grow px-2 py-1.5 text-text-secondary">
{status === 'running' && (
<div className="my-1 h-2 w-[72px] rounded-sm bg-text-quaternary" />
@ -86,7 +86,7 @@ const MetaData: FC<Props> = ({
</div>
</div>
<div className="flex">
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('runLog.meta.tokens')}</div>
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('meta.tokens', { ns: 'runLog' })}</div>
<div className="system-xs-regular grow px-2 py-1.5 text-text-secondary">
{status === 'running' && (
<div className="my-1 h-2 w-[48px] rounded-sm bg-text-quaternary" />
@ -98,7 +98,7 @@ const MetaData: FC<Props> = ({
</div>
{showSteps && (
<div className="flex">
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('runLog.meta.steps')}</div>
<div className="system-xs-regular w-[104px] shrink-0 truncate px-2 py-1.5 text-text-tertiary">{t('meta.steps', { ns: 'runLog' })}</div>
<div className="system-xs-regular grow px-2 py-1.5 text-text-secondary">
{status === 'running' && (
<div className="my-1 h-2 w-[24px] rounded-sm bg-text-quaternary" />

View File

@ -98,16 +98,16 @@ const NodePanel: FC<Props> = ({
const isToolNode = nodeInfo.node_type === BlockEnum.Tool && !!nodeInfo.agentLog?.length
const inputsTitle = useMemo(() => {
let text = t('workflow.common.input')
let text = t('common.input', { ns: 'workflow' })
if (nodeInfo.node_type === BlockEnum.Loop)
text = t('workflow.nodes.loop.initialLoopVariables')
text = t('nodes.loop.initialLoopVariables', { ns: 'workflow' })
return text.toLocaleUpperCase()
}, [nodeInfo.node_type, t])
const processDataTitle = t('workflow.common.processData').toLocaleUpperCase()
const processDataTitle = t('common.processData', { ns: 'workflow' }).toLocaleUpperCase()
const outputTitle = useMemo(() => {
let text = t('workflow.common.output')
let text = t('common.output', { ns: 'workflow' })
if (nodeInfo.node_type === BlockEnum.Loop)
text = t('workflow.nodes.loop.finalLoopVariables')
text = t('nodes.loop.finalLoopVariables', { ns: 'workflow' })
return text.toLocaleUpperCase()
}, [nodeInfo.node_type, t])
@ -204,7 +204,7 @@ const NodePanel: FC<Props> = ({
<div className={cn('mb-1', hideInfo && '!px-2 !py-0.5')}>
{(nodeInfo.status === 'stopped') && (
<StatusContainer status="stopped">
{t('workflow.tracing.stopBy', { user: nodeInfo.created_by ? nodeInfo.created_by.name : 'N/A' })}
{t('tracing.stopBy', { ns: 'workflow', user: nodeInfo.created_by ? nodeInfo.created_by.name : 'N/A' })}
</StatusContainer>
)}
{(nodeInfo.status === 'exception') && (
@ -215,7 +215,7 @@ const NodePanel: FC<Props> = ({
target="_blank"
className="text-text-accent"
>
{t('workflow.common.learnMore')}
{t('common.learnMore', { ns: 'workflow' })}
</a>
</StatusContainer>
)}

View File

@ -128,7 +128,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
<div className="flex flex-col gap-2 px-4 py-2">
<CodeEditor
readOnly
title={<div>{t('workflow.common.input').toLocaleUpperCase()}</div>}
title={<div>{t('common.input', { ns: 'workflow' }).toLocaleUpperCase()}</div>}
language={CodeLanguage.json}
value={inputs}
isJSONStringifyBeauty
@ -137,7 +137,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
{process_data && (
<CodeEditor
readOnly
title={<div>{t('workflow.common.processData').toLocaleUpperCase()}</div>}
title={<div>{t('common.processData', { ns: 'workflow' }).toLocaleUpperCase()}</div>}
language={CodeLanguage.json}
value={process_data}
isJSONStringifyBeauty
@ -147,7 +147,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
{(outputs || status === 'running') && (
<CodeEditor
readOnly
title={<div>{t('workflow.common.output').toLocaleUpperCase()}</div>}
title={<div>{t('common.output', { ns: 'workflow' }).toLocaleUpperCase()}</div>}
language={CodeLanguage.json}
value={outputs}
isJSONStringifyBeauty

View File

@ -40,11 +40,11 @@ const ResultText: FC<ResultTextProps> = ({
{!isRunning && !outputs && !error && !allFiles?.length && (
<div className="mt-[120px] flex flex-col items-center px-4 py-2 text-[13px] leading-[18px] text-gray-500">
<ImageIndentLeft className="h-6 w-6 text-gray-400" />
<div className="mr-2">{t('runLog.resultEmpty.title')}</div>
<div className="mr-2">{t('resultEmpty.title', { ns: 'runLog' })}</div>
<div>
{t('runLog.resultEmpty.tipLeft')}
<span onClick={onClick} className="cursor-pointer text-primary-600">{t('runLog.resultEmpty.link')}</span>
{t('runLog.resultEmpty.tipRight')}
{t('resultEmpty.tipLeft', { ns: 'runLog' })}
<span onClick={onClick} className="cursor-pointer text-primary-600">{t('resultEmpty.link', { ns: 'runLog' })}</span>
{t('resultEmpty.tipRight', { ns: 'runLog' })}
</div>
</div>
)}

View File

@ -31,7 +31,7 @@ const RetryLogTrigger = ({
>
<div className="flex items-center">
<RiRestartFill className="mr-0.5 h-4 w-4 shrink-0 text-components-button-tertiary-text" />
{t('workflow.nodes.common.retry.retries', { num: retryDetail?.length })}
{t('nodes.common.retry.retries', { ns: 'workflow', num: retryDetail?.length })}
</div>
<RiArrowRightSLine className="h-4 w-4 shrink-0 text-components-button-tertiary-text" />
</Button>

View File

@ -31,12 +31,12 @@ const RetryResultPanel: FC<Props> = ({
}}
>
<RiArrowLeftLine className="mr-1 h-4 w-4" />
{t('workflow.singleRun.back')}
{t('singleRun.back', { ns: 'workflow' })}
</div>
<TracingPanel
list={list.map((item, index) => ({
...item,
title: `${t('workflow.nodes.common.retry.retry')} ${index + 1}`,
title: `${t('nodes.common.retry.retry', { ns: 'workflow' })} ${index + 1}`,
}))}
className="bg-background-section-burn"
/>

View File

@ -34,7 +34,7 @@ const StatusPanel: FC<ResultProps> = ({
status === 'partial-succeeded' && 'min-w-[140px]',
)}
>
<div className="system-2xs-medium-uppercase mb-1 text-text-tertiary">{t('runLog.resultPanel.status')}</div>
<div className="system-2xs-medium-uppercase mb-1 text-text-tertiary">{t('resultPanel.status', { ns: 'runLog' })}</div>
<div
className={cn(
'system-xs-semibold-uppercase flex items-center gap-1',
@ -84,7 +84,7 @@ const StatusPanel: FC<ResultProps> = ({
</div>
</div>
<div className="max-w-[152px] flex-[33%]">
<div className="system-2xs-medium-uppercase mb-1 text-text-tertiary">{t('runLog.resultPanel.time')}</div>
<div className="system-2xs-medium-uppercase mb-1 text-text-tertiary">{t('resultPanel.time', { ns: 'runLog' })}</div>
<div className="system-sm-medium flex items-center gap-1 text-text-secondary">
{status === 'running' && (
<div className="h-2 w-16 rounded-sm bg-text-quaternary" />
@ -95,7 +95,7 @@ const StatusPanel: FC<ResultProps> = ({
</div>
</div>
<div className="flex-[33%]">
<div className="system-2xs-medium-uppercase mb-1 text-text-tertiary">{t('runLog.resultPanel.tokens')}</div>
<div className="system-2xs-medium-uppercase mb-1 text-text-tertiary">{t('resultPanel.tokens', { ns: 'runLog' })}</div>
<div className="system-sm-medium flex items-center gap-1 text-text-secondary">
{status === 'running' && (
<div className="h-2 w-20 rounded-sm bg-text-quaternary" />
@ -115,7 +115,7 @@ const StatusPanel: FC<ResultProps> = ({
<>
<div className="my-2 h-[0.5px] bg-divider-subtle" />
<div className="system-xs-regular text-text-destructive">
{t('workflow.nodes.common.errorHandle.partialSucceeded.tip', { num: exceptionCounts })}
{t('nodes.common.errorHandle.partialSucceeded.tip', { ns: 'workflow', num: exceptionCounts })}
</div>
</>
)
@ -127,7 +127,7 @@ const StatusPanel: FC<ResultProps> = ({
<>
<div className="my-2 h-[0.5px] bg-divider-deep" />
<div className="system-xs-medium text-text-warning">
{t('workflow.nodes.common.errorHandle.partialSucceeded.tip', { num: exceptionCounts })}
{t('nodes.common.errorHandle.partialSucceeded.tip', { ns: 'workflow', num: exceptionCounts })}
</div>
</>
)
@ -143,7 +143,7 @@ const StatusPanel: FC<ResultProps> = ({
target="_blank"
className="text-text-accent"
>
{t('workflow.common.learnMore')}
{t('common.learnMore', { ns: 'workflow' })}
</a>
</div>
</>

View File

@ -44,7 +44,7 @@ function addTitle({
if (isParallelStartNode) {
node.parallelDetail!.isParallelStartNode = true
node.parallelDetail!.parallelTitle = `${t('workflow.common.parallel')}-${parallelIndexInfo}`
node.parallelDetail!.parallelTitle = `${t('common.parallel', { ns: 'workflow' })}-${parallelIndexInfo}`
}
const isBrachStartNode = parallel_start_node_id === node.node_id
@ -57,7 +57,7 @@ function addTitle({
}
}
node.parallelDetail!.branchTitle = `${t('workflow.common.branch')}-${belongParallelIndexInfo}-${branchLetter}`
node.parallelDetail!.branchTitle = `${t('common.branch', { ns: 'workflow' })}-${belongParallelIndexInfo}-${branchLetter}`
}
if (node.parallelDetail?.children && node.parallelDetail.children.length > 0) {