balibabu commited on
Commit
838db53
·
1 Parent(s): 12defec

feat: translate fields of CategorizeForm #918 (#1311)

Browse files

### What problem does this PR solve?

feat: translate fields of CategorizeForm #918
### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/src/locales/en.ts CHANGED
@@ -544,7 +544,15 @@ The above is the content you need to summarize.`,
544
  preview: 'Preview',
545
  fileError: 'File error',
546
  },
547
- flow: { cite: 'Cite', citeTip: 'citeTip' },
 
 
 
 
 
 
 
 
548
  footer: {
549
  profile: 'All rights reserved @ React',
550
  },
 
544
  preview: 'Preview',
545
  fileError: 'File error',
546
  },
547
+ flow: {
548
+ cite: 'Cite',
549
+ citeTip: 'citeTip',
550
+ name: 'Name',
551
+ nameMessage: 'Please input name',
552
+ description: 'Description',
553
+ examples: 'Examples',
554
+ to: 'To',
555
+ },
556
  footer: {
557
  profile: 'All rights reserved @ React',
558
  },
web/src/locales/zh-traditional.ts CHANGED
@@ -505,7 +505,15 @@ export default {
505
  preview: '預覽',
506
  fileError: '文件錯誤',
507
  },
508
- flow: { cite: '引用', citeTip: 'citeTip' },
 
 
 
 
 
 
 
 
509
  footer: {
510
  profile: '“保留所有權利 @ react”',
511
  },
 
505
  preview: '預覽',
506
  fileError: '文件錯誤',
507
  },
508
+ flow: {
509
+ cite: '引用',
510
+ citeTip: 'citeTip',
511
+ name: '名稱',
512
+ nameMessage: '請輸入名稱',
513
+ description: '描述',
514
+ examples: '範例',
515
+ to: '到',
516
+ },
517
  footer: {
518
  profile: '“保留所有權利 @ react”',
519
  },
web/src/locales/zh.ts CHANGED
@@ -523,7 +523,15 @@ export default {
523
  preview: '预览',
524
  fileError: '文件错误',
525
  },
526
- flow: { cite: '引用', citeTip: 'citeTip' },
 
 
 
 
 
 
 
 
527
  footer: {
528
  profile: 'All rights reserved @ React',
529
  },
 
523
  preview: '预览',
524
  fileError: '文件错误',
525
  },
526
+ flow: {
527
+ cite: '引用',
528
+ citeTip: 'citeTip',
529
+ name: '名称',
530
+ nameMessage: '请输入名称',
531
+ description: '描述',
532
+ examples: '示例',
533
+ to: '到',
534
+ },
535
  footer: {
536
  profile: 'All rights reserved @ React',
537
  },
web/src/pages/flow/categorize-form/dynamic-categorize.tsx CHANGED
@@ -1,3 +1,4 @@
 
1
  import { CloseOutlined } from '@ant-design/icons';
2
  import { Button, Card, Form, Input, Select, Typography } from 'antd';
3
  import { useUpdateNodeInternals } from 'reactflow';
@@ -13,6 +14,7 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
13
  const form = Form.useFormInstance();
14
  const buildCategorizeToOptions = useBuildCategorizeToOptions();
15
  const { handleSelectChange } = useHandleToSelectChange(nodeId);
 
16
 
17
  return (
18
  <>
@@ -40,25 +42,25 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
40
  }
41
  >
42
  <Form.Item
43
- label="name"
44
  name={[field.name, 'name']}
45
- // initialValue={`Categorize ${field.name + 1}`}
46
- rules={[
47
- { required: true, message: 'Please input your name!' },
48
- ]}
49
  >
50
  <Input />
51
  </Form.Item>
52
  <Form.Item
53
- label="description"
54
  name={[field.name, 'description']}
55
  >
56
  <Input.TextArea rows={3} />
57
  </Form.Item>
58
- <Form.Item label="examples" name={[field.name, 'examples']}>
 
 
 
59
  <Input.TextArea rows={3} />
60
  </Form.Item>
61
- <Form.Item label="to" name={[field.name, 'to']}>
62
  <Select
63
  allowClear
64
  options={buildCategorizeToOptions(
 
1
+ import { useTranslate } from '@/hooks/commonHooks';
2
  import { CloseOutlined } from '@ant-design/icons';
3
  import { Button, Card, Form, Input, Select, Typography } from 'antd';
4
  import { useUpdateNodeInternals } from 'reactflow';
 
14
  const form = Form.useFormInstance();
15
  const buildCategorizeToOptions = useBuildCategorizeToOptions();
16
  const { handleSelectChange } = useHandleToSelectChange(nodeId);
17
+ const { t } = useTranslate('flow');
18
 
19
  return (
20
  <>
 
42
  }
43
  >
44
  <Form.Item
45
+ label={t('name')}
46
  name={[field.name, 'name']}
47
+ rules={[{ required: true, message: t('nameMessage') }]}
 
 
 
48
  >
49
  <Input />
50
  </Form.Item>
51
  <Form.Item
52
+ label={t('description')}
53
  name={[field.name, 'description']}
54
  >
55
  <Input.TextArea rows={3} />
56
  </Form.Item>
57
+ <Form.Item
58
+ label={t('examples')}
59
+ name={[field.name, 'examples']}
60
+ >
61
  <Input.TextArea rows={3} />
62
  </Form.Item>
63
+ <Form.Item label={t('to')} name={[field.name, 'to']}>
64
  <Select
65
  allowClear
66
  options={buildCategorizeToOptions(
web/src/pages/flow/message-form/index.tsx ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useTranslate } from '@/hooks/commonHooks';
2
+ import type { FormProps } from 'antd';
3
+ import { Form, Input } from 'antd';
4
+ import { IOperatorForm } from '../interface';
5
+
6
+ type FieldType = {
7
+ prologue?: string;
8
+ };
9
+
10
+ const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
11
+ console.log('Success:', values);
12
+ };
13
+
14
+ const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
15
+ console.log('Failed:', errorInfo);
16
+ };
17
+
18
+ const MessageForm = ({ onValuesChange, form }: IOperatorForm) => {
19
+ const { t } = useTranslate('chat');
20
+
21
+ return (
22
+ <Form
23
+ name="basic"
24
+ labelCol={{ span: 8 }}
25
+ wrapperCol={{ span: 16 }}
26
+ style={{ maxWidth: 600 }}
27
+ initialValues={{ remember: true }}
28
+ onFinish={onFinish}
29
+ onFinishFailed={onFinishFailed}
30
+ onValuesChange={onValuesChange}
31
+ autoComplete="off"
32
+ form={form}
33
+ >
34
+ <Form.Item<FieldType>
35
+ name={'prologue'}
36
+ label={t('setAnOpener')}
37
+ tooltip={t('setAnOpenerTip')}
38
+ initialValue={t('setAnOpenerInitial')}
39
+ >
40
+ <Input.TextArea autoSize={{ minRows: 5 }} />
41
+ </Form.Item>
42
+ </Form>
43
+ );
44
+ };
45
+
46
+ export default MessageForm;