feat: translate name of operator #918 (#1437)

### What problem does this PR solve?

feat: translate name of operator #918

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2024-07-09 13:22:37 +08:00 committed by GitHub
parent 56e3fa2d6a
commit 198a8b6592
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 27 additions and 30 deletions

View File

@ -1,4 +1,3 @@
import { useTranslate } from '@/hooks/commonHooks';
import { ResponseType } from '@/interfaces/database/base'; import { ResponseType } from '@/interfaces/database/base';
import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow'; import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow';
import i18n from '@/locales/config'; import i18n from '@/locales/config';
@ -46,7 +45,6 @@ export const EmptyDsl = {
}; };
export const useFetchFlowTemplates = (): ResponseType<IFlowTemplate[]> => { export const useFetchFlowTemplates = (): ResponseType<IFlowTemplate[]> => {
const { t } = useTranslate('flow');
const { data } = useQuery({ const { data } = useQuery({
queryKey: ['fetchFlowTemplates'], queryKey: ['fetchFlowTemplates'],
initialData: [], initialData: [],
@ -55,8 +53,8 @@ export const useFetchFlowTemplates = (): ResponseType<IFlowTemplate[]> => {
if (Array.isArray(data?.data)) { if (Array.isArray(data?.data)) {
data.data.unshift({ data.data.unshift({
id: uuid(), id: uuid(),
title: t('blank'), title: 'Blank',
description: t('createFromNothing'), description: 'Create from nothing',
dsl: EmptyDsl, dsl: EmptyDsl,
}); });
} }

View File

@ -554,7 +554,7 @@ The above is the content you need to summarize.`,
description: 'Description', description: 'Description',
examples: 'Examples', examples: 'Examples',
to: 'To', to: 'To',
message: 'Messages', msg: 'Messages',
messagePlaceholder: 'message', messagePlaceholder: 'message',
messageMsg: 'Please input message or delete this field.', messageMsg: 'Please input message or delete this field.',
addField: 'Add field', addField: 'Add field',
@ -591,9 +591,11 @@ The above is the content you need to summarize.`,
relevant: 'Relevant', relevant: 'Relevant',
rewriteQuestion: 'RewriteQuestion', rewriteQuestion: 'RewriteQuestion',
rewrite: 'Rewrite', rewrite: 'Rewrite',
Begin: 'Begin', begin: 'Begin',
message: 'Message',
blank: 'Blank', blank: 'Blank',
createFromNothing: 'Create from nothing', createFromNothing: 'Create from nothing',
addItem: 'Add Item',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

View File

@ -515,7 +515,7 @@ export default {
description: '描述', description: '描述',
examples: '範例', examples: '範例',
to: '下一步', to: '下一步',
message: '訊息', msg: '訊息',
messagePlaceholder: '訊息', messagePlaceholder: '訊息',
messageMsg: '請輸入訊息或刪除此欄位。', messageMsg: '請輸入訊息或刪除此欄位。',
addField: '新增字段', addField: '新增字段',
@ -546,16 +546,17 @@ export default {
`, `,
createGraph: '建立圖表', createGraph: '建立圖表',
createFromTemplates: '從模板創建', createFromTemplates: '從模板創建',
retrieval: '檢索', retrieval: '知識檢索',
generate: '產生', generate: '生成回答',
answer: '回答', answer: '人機交互',
categorize: '分類', categorize: '問題分類',
relevant: '相關', relevant: '是否相關',
rewriteQuestion: '重組', rewriteQuestion: '問題最佳化',
rewrite: '重組',
begin: '開始', begin: '開始',
message: '靜態訊息',
blank: '空', blank: '空',
createFromNothing: '從無到有', createFromNothing: '從無到有',
addItem: '新增',
}, },
footer: { footer: {
profile: '“保留所有權利 @ react”', profile: '“保留所有權利 @ react”',

View File

@ -534,7 +534,7 @@ export default {
description: '描述', description: '描述',
examples: '示例', examples: '示例',
to: '下一步', to: '下一步',
message: '消息', msg: '消息',
messagePlaceholder: '消息', messagePlaceholder: '消息',
messageMsg: '请输入消息或删除此字段。', messageMsg: '请输入消息或删除此字段。',
addField: '新增字段', addField: '新增字段',
@ -564,16 +564,17 @@ export default {
`, `,
createGraph: '创建图表', createGraph: '创建图表',
createFromTemplates: '从模板创建', createFromTemplates: '从模板创建',
retrieval: '检索', retrieval: '知识检索',
generate: '生成', generate: '生成回答',
answer: '回答', answer: '人机交互',
categorize: '分类', categorize: '问题分类',
relevant: '相关', relevant: '是否相关',
rewriteQuestion: '重组', rewriteQuestion: '问题优化',
rewrite: '重组',
begin: '开始', begin: '开始',
message: '静态消息',
blank: '空', blank: '空',
createFromNothing: '从无到有', createFromNothing: '从无到有',
addItem: '新增',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

View File

@ -1,8 +1,6 @@
import { Handle, Position } from 'reactflow'; import { Handle, Position } from 'reactflow';
// import { v4 as uuid } from 'uuid'; // import { v4 as uuid } from 'uuid';
import { useTranslate } from '@/hooks/commonHooks';
import lowerFirst from 'lodash/lowerFirst';
import styles from './index.less'; import styles from './index.less';
const DEFAULT_HANDLE_STYLE = { const DEFAULT_HANDLE_STYLE = {
@ -20,7 +18,6 @@ interface IProps {
} }
const CategorizeHandle = ({ top, right, text, idx }: IProps) => { const CategorizeHandle = ({ top, right, text, idx }: IProps) => {
const { t } = useTranslate('flow');
return ( return (
<Handle <Handle
type="source" type="source"
@ -36,9 +33,7 @@ const CategorizeHandle = ({ top, right, text, idx }: IProps) => {
color: 'black', color: 'black',
}} }}
> >
<span className={styles.categorizeAnchorPointText}> <span className={styles.categorizeAnchorPointText}>{text}</span>
{lowerFirst(t(text))}
</span>
</Handle> </Handle>
); );
}; };

View File

@ -88,7 +88,7 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
))} ))}
<Button type="dashed" onClick={handleAdd} block> <Button type="dashed" onClick={handleAdd} block>
+ Add Item + {t('addItem')}
</Button> </Button>
</div> </div>
); );

View File

@ -38,7 +38,7 @@ const MessageForm = ({ onValuesChange, form }: IOperatorForm) => {
{fields.map((field, index) => ( {fields.map((field, index) => (
<Form.Item <Form.Item
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)} {...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
label={index === 0 ? t('message') : ''} label={index === 0 ? t('msg') : ''}
required={false} required={false}
key={field.key} key={field.key}
> >