### What problem does this PR solve? feat: translate name of operator #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.9.0
| 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'; | ||||
| }; | }; | ||||
| 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: [], | ||||
| if (Array.isArray(data?.data)) { | if (Array.isArray(data?.data)) { | ||||
| data.data.unshift({ | data.data.unshift({ | ||||
| id: uuid(), | id: uuid(), | ||||
| title: t('blank'), | |||||
| description: t('createFromNothing'), | |||||
| title: 'Blank', | |||||
| description: 'Create from nothing', | |||||
| dsl: EmptyDsl, | dsl: EmptyDsl, | ||||
| }); | }); | ||||
| } | } |
| 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', | ||||
| 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', |
| description: '描述', | description: '描述', | ||||
| examples: '範例', | examples: '範例', | ||||
| to: '下一步', | to: '下一步', | ||||
| message: '訊息', | |||||
| msg: '訊息', | |||||
| messagePlaceholder: '訊息', | messagePlaceholder: '訊息', | ||||
| messageMsg: '請輸入訊息或刪除此欄位。', | messageMsg: '請輸入訊息或刪除此欄位。', | ||||
| addField: '新增字段', | addField: '新增字段', | ||||
| 以上就是你需要總結的內容。`, | 以上就是你需要總結的內容。`, | ||||
| createGraph: '建立圖表', | createGraph: '建立圖表', | ||||
| createFromTemplates: '從模板創建', | createFromTemplates: '從模板創建', | ||||
| retrieval: '檢索', | |||||
| generate: '產生', | |||||
| answer: '回答', | |||||
| categorize: '分類', | |||||
| relevant: '相關', | |||||
| rewriteQuestion: '重組', | |||||
| rewrite: '重組', | |||||
| retrieval: '知識檢索', | |||||
| generate: '生成回答', | |||||
| answer: '人機交互', | |||||
| categorize: '問題分類', | |||||
| relevant: '是否相關', | |||||
| rewriteQuestion: '問題最佳化', | |||||
| begin: '開始', | begin: '開始', | ||||
| message: '靜態訊息', | |||||
| blank: '空', | blank: '空', | ||||
| createFromNothing: '從無到有', | createFromNothing: '從無到有', | ||||
| addItem: '新增', | |||||
| }, | }, | ||||
| footer: { | footer: { | ||||
| profile: '“保留所有權利 @ react”', | profile: '“保留所有權利 @ react”', |
| description: '描述', | description: '描述', | ||||
| examples: '示例', | examples: '示例', | ||||
| to: '下一步', | to: '下一步', | ||||
| message: '消息', | |||||
| msg: '消息', | |||||
| messagePlaceholder: '消息', | messagePlaceholder: '消息', | ||||
| messageMsg: '请输入消息或删除此字段。', | messageMsg: '请输入消息或删除此字段。', | ||||
| addField: '新增字段', | addField: '新增字段', | ||||
| 以上就是你需要总结的内容。`, | 以上就是你需要总结的内容。`, | ||||
| createGraph: '创建图表', | createGraph: '创建图表', | ||||
| createFromTemplates: '从模板创建', | createFromTemplates: '从模板创建', | ||||
| retrieval: '检索', | |||||
| generate: '生成', | |||||
| answer: '回答', | |||||
| categorize: '分类', | |||||
| relevant: '相关', | |||||
| rewriteQuestion: '重组', | |||||
| rewrite: '重组', | |||||
| retrieval: '知识检索', | |||||
| generate: '生成回答', | |||||
| answer: '人机交互', | |||||
| categorize: '问题分类', | |||||
| relevant: '是否相关', | |||||
| rewriteQuestion: '问题优化', | |||||
| begin: '开始', | begin: '开始', | ||||
| message: '静态消息', | |||||
| blank: '空', | blank: '空', | ||||
| createFromNothing: '从无到有', | createFromNothing: '从无到有', | ||||
| addItem: '新增', | |||||
| }, | }, | ||||
| footer: { | footer: { | ||||
| profile: 'All rights reserved @ React', | profile: 'All rights reserved @ React', |
| 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 = { | ||||
| } | } | ||||
| 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" | ||||
| color: 'black', | color: 'black', | ||||
| }} | }} | ||||
| > | > | ||||
| <span className={styles.categorizeAnchorPointText}> | |||||
| {lowerFirst(t(text))} | |||||
| </span> | |||||
| <span className={styles.categorizeAnchorPointText}>{text}</span> | |||||
| </Handle> | </Handle> | ||||
| ); | ); | ||||
| }; | }; |
| ))} | ))} | ||||
| <Button type="dashed" onClick={handleAdd} block> | <Button type="dashed" onClick={handleAdd} block> | ||||
| + Add Item | |||||
| + {t('addItem')} | |||||
| </Button> | </Button> | ||||
| </div> | </div> | ||||
| ); | ); |
| {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} | ||||
| > | > |