Feat: Translate the parser operator #9869 (#10037)

### What problem does this PR solve?

Feat: Translate the parser operator #9869

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-09-11 11:07:26 +08:00
committed by GitHub
parent 1936ad82d2
commit d14d92a900
6 changed files with 38 additions and 12 deletions

View File

@ -1628,5 +1628,13 @@ This delimiter is used to split the input text into several text pieces echo of
rerunFromCurrentStep: 'Rerun From Current Step', rerunFromCurrentStep: 'Rerun From Current Step',
rerunFromCurrentStepTip: 'Changes detected. Click to re-run.', rerunFromCurrentStepTip: 'Changes detected. Click to re-run.',
}, },
dataflow: {
parser: 'Parser',
parserDescription: 'Parser',
chunker: 'Chunker',
chunkerDescription: 'Chunker',
tokenizer: 'Tokenizer',
tokenizerDescription: 'Tokenizer',
},
}, },
}; };

View File

@ -1536,5 +1536,13 @@ General实体和关系提取提示来自 GitHub - microsoft/graphrag基于
rerunFromCurrentStep: '从当前步骤重新运行', rerunFromCurrentStep: '从当前步骤重新运行',
rerunFromCurrentStepTip: '已修改,点击重新运行。', rerunFromCurrentStepTip: '已修改,点击重新运行。',
}, },
dataflow: {
parser: '解析器',
parserDescription: '解析器',
chunker: '分块器',
chunkerDescription: '分块器',
tokenizer: '分词器',
tokenizerDescription: '分词器',
},
}, },
}; };

View File

@ -17,9 +17,9 @@ import {
TooltipTrigger, TooltipTrigger,
} from '@/components/ui/tooltip'; } from '@/components/ui/tooltip';
import { IModalProps } from '@/interfaces/common'; import { IModalProps } from '@/interfaces/common';
import { useGetNodeDescription, useGetNodeName } from '@/pages/data-flow/hooks';
import { Position } from '@xyflow/react'; import { Position } from '@xyflow/react';
import { t } from 'i18next'; import { t } from 'i18next';
import { lowerFirst } from 'lodash';
import { import {
PropsWithChildren, PropsWithChildren,
createContext, createContext,
@ -28,7 +28,6 @@ import {
useEffect, useEffect,
useRef, useRef,
} from 'react'; } from 'react';
import { useTranslation } from 'react-i18next';
import { Operator } from '../../../constant'; import { Operator } from '../../../constant';
import { AgentInstanceContext, HandleContext } from '../../../context'; import { AgentInstanceContext, HandleContext } from '../../../context';
import OperatorIcon from '../../../operator-icon'; import OperatorIcon from '../../../operator-icon';
@ -53,7 +52,9 @@ function OperatorItemList({
const handleContext = useContext(HandleContext); const handleContext = useContext(HandleContext);
const hideModal = useContext(HideModalContext); const hideModal = useContext(HideModalContext);
const onNodeCreated = useContext(OnNodeCreatedContext); const onNodeCreated = useContext(OnNodeCreatedContext);
const { t } = useTranslation();
const getNodeName = useGetNodeName();
const getNodeDescription = useGetNodeDescription();
const handleClick = (operator: Operator) => { const handleClick = (operator: Operator) => {
const contextData = handleContext || { const contextData = handleContext || {
@ -84,7 +85,7 @@ function OperatorItemList({
const commonContent = ( const commonContent = (
<div className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start"> <div className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start">
<OperatorIcon name={operator} /> <OperatorIcon name={operator} />
{t(`flow.${lowerFirst(operator)}`)} {getNodeName(operator)}
</div> </div>
); );
@ -101,12 +102,12 @@ function OperatorItemList({
onSelect={() => hideModal?.()} onSelect={() => hideModal?.()}
> >
<OperatorIcon name={operator} /> <OperatorIcon name={operator} />
{t(`flow.${lowerFirst(operator)}`)} {getNodeName(operator)}
</DropdownMenuItem> </DropdownMenuItem>
)} )}
</TooltipTrigger> </TooltipTrigger>
<TooltipContent side="right"> <TooltipContent side="right">
<p>{t(`flow.${lowerFirst(operator)}Description`)}</p> <p>{getNodeDescription(operator)}</p>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
); );

View File

@ -5,13 +5,13 @@ import {
SheetHeader, SheetHeader,
SheetTitle, SheetTitle,
} from '@/components/ui/sheet'; } from '@/components/ui/sheet';
import { useTranslate } from '@/hooks/common-hooks';
import { IModalProps } from '@/interfaces/common'; import { IModalProps } from '@/interfaces/common';
import { RAGFlowNodeType } from '@/interfaces/database/flow'; import { RAGFlowNodeType } from '@/interfaces/database/flow';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { lowerFirst } from 'lodash'; import { lowerFirst } from 'lodash';
import { Play, X } from 'lucide-react'; import { Play, X } from 'lucide-react';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { BeginId, Operator } from '../constant'; import { BeginId, Operator } from '../constant';
import { AgentFormContext } from '../context'; import { AgentFormContext } from '../context';
import { RunTooltip } from '../flow-tooltip'; import { RunTooltip } from '../flow-tooltip';
@ -60,7 +60,7 @@ const FormSheet = ({
); );
}, [clickedToolId, operatorName]); }, [clickedToolId, operatorName]);
const { t } = useTranslate('flow'); const { t } = useTranslation();
return ( return (
<Sheet open={visible} modal={false}> <Sheet open={visible} modal={false}>
@ -80,7 +80,7 @@ const FormSheet = ({
<div className="flex-1">MCP Config</div> <div className="flex-1">MCP Config</div>
) : ( ) : (
<div className="flex items-center gap-1 flex-1"> <div className="flex items-center gap-1 flex-1">
<label htmlFor="">{t('title')}</label> <label htmlFor="">{t('flow.title')}</label>
{node?.id === BeginId ? ( {node?.id === BeginId ? (
<span>{t(BeginId)}</span> <span>{t(BeginId)}</span>
) : ( ) : (
@ -106,7 +106,7 @@ const FormSheet = ({
{isMcp || ( {isMcp || (
<span> <span>
{t( {t(
`${lowerFirst(operatorName === Operator.Tool ? clickedToolId : operatorName)}Description`, `dataflow.${lowerFirst(operatorName === Operator.Tool ? clickedToolId : operatorName)}Description`,
)} )}
</span> </span>
)} )}

View File

@ -30,7 +30,16 @@ export const useGetNodeName = () => {
const { t } = useTranslation(); const { t } = useTranslation();
return (type: string) => { return (type: string) => {
const name = t(`flow.${lowerFirst(type)}`); const name = t(`dataflow.${lowerFirst(type)}`);
return name;
};
};
export const useGetNodeDescription = () => {
const { t } = useTranslation();
return (type: string) => {
const name = t(`dataflow.${lowerFirst(type)}Description`);
return name; return name;
}; };
}; };

View File

@ -108,7 +108,7 @@ export const useGetNodeName = () => {
const { t } = useTranslation(); const { t } = useTranslation();
return (type: string) => { return (type: string) => {
const name = t(`flow.${lowerFirst(type)}`); const name = t(`dataflow.${lowerFirst(type)}`);
return name; return name;
}; };
}; };