Explorar o código

locale(device): product metadata add translate

1175160654 %!s(int64=4) %!d(string=hai) anos
pai
achega
74e7e8ff86

+ 26 - 4
src/locales/en-US/pages.ts

@@ -145,7 +145,11 @@ export default {
   'pages.system.tenant.memberManagement.addUser': 'Add User',
   // 系统设置-数据源管理
   'pages.system.datasource.': 'DataSource',
-
+  // 设备管理-物模型
+  'pages.device.metadata.functions': 'Function',
+  'pages.device.metadata.properties': 'Property',
+  'pages.device.metadata.events': 'Events',
+  'pages.device.metadata.tags': 'Tag',
   // 设备管理-产品
   'pages.device.product': 'Product Manage',
   'pages.device.product.deviceNumber': 'Number of Devices',
@@ -163,15 +167,33 @@ export default {
   'pages.device.productDetail.base.save': 'Save',
   'pages.device.productDetail.metadata': 'Metadata',
   'pages.device.productDetail.metadata.quickImport': 'Quick Import',
-  'pages.device.productDetail.metadata.attributeDefinition': 'Attribute Definition',
+  'pages.device.productDetail.metadata.propertyDefinition': 'Property Definition',
   'pages.device.productDetail.metadata.functionDefinition': 'Function Definition',
   'pages.device.productDetail.metadata.eventDefinition': 'Event Definition',
-  'pages.device.productDetail.metadata.labelDefinition': 'Label Definition',
-  'pages.device.productDetail.metadata.lidentification': 'Lidentification',
+  'pages.device.productDetail.metadata.tagDefinition': 'Tag Definition',
+  'pages.device.productDetail.metadata.key': 'Key',
   'pages.device.productDetail.metadata.eventLevel': 'Event Level',
+  'pages.device.productDetail.metadata.level': 'Level',
   'pages.device.productDetail.metadata.whetherAsync': 'Whether Async',
   'pages.device.productDetail.metadata.whetherReadOnly': 'Whether ReadOnly',
+  'pages.device.productDetail.metadata.true': 'true',
+  'pages.device.productDetail.metadata.false': 'false',
   'pages.device.productDetail.metadata.dataType': 'Data Type',
+  'pages.device.productDetail.metadata.getData': 'Get Data',
+  'pages.device.productDetail.metadata.accuracy': 'Accuracy',
+  'pages.device.productDetail.metadata.boolean': 'Boolean',
+  'pages.device.productDetail.metadata.timeFormat': 'Time Format',
+  'pages.device.productDetail.metadata.enum': 'Enum',
+  'pages.device.productDetail.metadata.maxLength': 'Max Length',
+  'pages.device.productDetail.metadata.maxLength.byte': 'Byte',
+  'pages.device.productDetail.metadata.elementConfiguration': 'Element Configuration',
+  'pages.device.productDetail.metadata.jsonObject': 'JSON Object',
+  'pages.device.productDetail.metadata.fileType': 'File Type',
+  'pages.device.productDetail.metadata.source': 'Source',
+  'pages.device.productDetail.metadata.otherConfiguration': 'Other Configuration',
+  'pages.device.productDetail.metadata.describe': 'Describe',
+  'pages.device.productDetail.metadata.inputParameter': 'Input Parameter',
+  'pages.device.productDetail.metadata.outputParameters': 'Output Parameters',
   'pages.device.productDetail.alarm': 'Alarm Set',
   'pages.device.productDetail.alarmLog': 'Alarm Log',
   'pages.device.productDetail.alarmLog.deviceId': 'Device Id',

+ 24 - 6
src/locales/zh-CN/pages.ts

@@ -147,10 +147,10 @@ export default {
   'pages.system.datasource.': '数据源管理',
 
   // 设备管理-物模型
-  'pages.device.metadata.function': '功能',
-  'pages.device.metadata.property': '属性',
+  'pages.device.metadata.functions': '功能',
+  'pages.device.metadata.properties': '属性',
   'pages.device.metadata.events': '事件',
-  'pages.device.metadata.tag': '标签',
+  'pages.device.metadata.tags': '标签',
   // 设备管理-产品
   'pages.device.product': '产品',
   'pages.device.product.deviceNumber': '设备数量',
@@ -168,15 +168,33 @@ export default {
   'pages.device.productDetail.base.save': '保存',
   'pages.device.productDetail.metadata': '物模型',
   'pages.device.productDetail.metadata.quickImport': '快速导入',
-  'pages.device.productDetail.metadata.attributeDefinition': '属性定义',
+  'pages.device.productDetail.metadata.propertyDefinition': '属性定义',
   'pages.device.productDetail.metadata.functionDefinition': '功能定义',
   'pages.device.productDetail.metadata.eventDefinition': '事件定义',
-  'pages.device.productDetail.metadata.labelDefinition': '标签定义',
-  'pages.device.productDetail.metadata.lidentification': '标识',
+  'pages.device.productDetail.metadata.tagDefinition': '标签定义',
+  'pages.device.productDetail.metadata.key': '标识',
   'pages.device.productDetail.metadata.eventLevel': '事件级别',
+  'pages.device.productDetail.metadata.level': '级别',
   'pages.device.productDetail.metadata.whetherAsync': '是否异步',
   'pages.device.productDetail.metadata.whetherReadOnly': '是否只读',
+  'pages.device.productDetail.metadata.true': '是',
+  'pages.device.productDetail.metadata.false': '否',
   'pages.device.productDetail.metadata.dataType': '数据类型',
+  'pages.device.productDetail.metadata.getData': '获取数据',
+  'pages.device.productDetail.metadata.accuracy': '精度',
+  'pages.device.productDetail.metadata.boolean': '布尔值',
+  'pages.device.productDetail.metadata.timeFormat': '时间格式',
+  'pages.device.productDetail.metadata.enum': '枚举项',
+  'pages.device.productDetail.metadata.maxLength': '最大长度',
+  'pages.device.productDetail.metadata.maxLength.byte': '字节',
+  'pages.device.productDetail.metadata.elementConfiguration': '元素配置',
+  'pages.device.productDetail.metadata.jsonObject': 'JSON对象',
+  'pages.device.productDetail.metadata.fileType': '文件类型',
+  'pages.device.productDetail.metadata.source': '来源',
+  'pages.device.productDetail.metadata.otherConfiguration': '其他配置',
+  'pages.device.productDetail.metadata.describe': '描述',
+  'pages.device.productDetail.metadata.inputParameter': '输入参数',
+  'pages.device.productDetail.metadata.outputParameters': '输出参数',
   'pages.device.productDetail.alarm': '告警设置',
   'pages.device.productDetail.alarmLog': '告警记录',
   'pages.device.productDetail.alarmLog.deviceId': '设备ID',

+ 154 - 41
src/pages/device/Product/Detail/Metadata/Base/Edit/index.tsx

@@ -37,6 +37,7 @@ import { useIntl } from '@@/plugin-locale/localeExports';
 import { lastValueFrom } from 'rxjs';
 
 const Edit = () => {
+  const intl = useIntl();
   const form = createForm({
     initialValues: MetadataModel.item as Record<string, unknown>,
   });
@@ -94,13 +95,19 @@ const Edit = () => {
     type: 'object',
     properties: {
       id: {
-        title: '标识',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.key',
+          defaultMessage: '标识',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       name: {
-        title: '名称',
+        title: intl.formatMessage({
+          id: 'pages.table.name',
+          defaultMessage: '名称',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
@@ -109,14 +116,20 @@ const Edit = () => {
         type: 'object',
         properties: {
           type: {
-            title: '数据类型',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.dataType',
+              defaultMessage: '数据类型',
+            }),
             required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             enum: DataTypeList,
           },
           unit: {
-            title: '单位',
+            title: intl.formatMessage({
+              id: 'pages.device.instanceDetail.metadata.unit',
+              defaultMessage: '单位',
+            }),
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             'x-visible': false,
@@ -131,7 +144,10 @@ const Edit = () => {
             },
           },
           scale: {
-            title: '精度',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.accuracy',
+              defaultMessage: '精度',
+            }),
             'x-decorator': 'FormItem',
             'x-component': 'NumberPicker',
             'x-reactions': {
@@ -144,7 +160,10 @@ const Edit = () => {
             },
           },
           booleanConfig: {
-            title: '布尔值',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.boolean',
+              defaultMessage: '布尔值',
+            }),
             type: 'void',
             'x-decorator': 'FormItem',
             'x-component': 'BooleanEnum',
@@ -158,7 +177,10 @@ const Edit = () => {
             },
           },
           format: {
-            title: '时间格式',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.timeFormat',
+              defaultMessage: '时间格式',
+            }),
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             enum: DateTypeList,
@@ -172,7 +194,10 @@ const Edit = () => {
             },
           },
           enumConfig: {
-            title: '枚举项',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.enum',
+              defaultMessage: '枚举项',
+            }),
             type: 'void',
             'x-decorator': 'FormItem',
             'x-component': 'EnumParam',
@@ -189,11 +214,17 @@ const Edit = () => {
             type: 'object',
             properties: {
               maxLength: {
-                title: '最大长度',
+                title: intl.formatMessage({
+                  id: 'pages.device.productDetail.metadata.maxLength',
+                  defaultMessage: '最大长度',
+                }),
                 'x-decorator': 'FormItem',
                 'x-component': 'NumberPicker',
                 'x-decorator-props': {
-                  tooltip: '字节',
+                  tooltip: intl.formatMessage({
+                    id: 'pages.device.productDetail.metadata.maxLength.byte',
+                    defaultMessage: '字节',
+                  }),
                 },
                 'x-reactions': {
                   dependencies: ['..type'],
@@ -207,7 +238,10 @@ const Edit = () => {
             },
           },
           elementType: {
-            title: '元素配置',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.elementConfiguration',
+              defaultMessage: '元素配置',
+            }),
             'x-decorator': 'FormItem',
             'x-component': 'ArrayParam',
             'x-reactions': {
@@ -220,7 +254,10 @@ const Edit = () => {
             },
           },
           jsonConfig: {
-            title: 'JSON对象',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.jsonObject',
+              defaultMessage: 'JSON对象',
+            }),
             type: 'void',
             'x-decorator': 'FormItem',
             'x-component': 'JsonParam',
@@ -234,7 +271,10 @@ const Edit = () => {
             },
           },
           fileType: {
-            title: '文件类型',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.fileType',
+              defaultMessage: '文件类型',
+            }),
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             'x-visible': false,
@@ -254,24 +294,36 @@ const Edit = () => {
         type: 'object',
         properties: {
           source: {
-            title: '来源',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.source',
+              defaultMessage: '来源',
+            }),
             required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             enum: PropertySource,
           },
           readOnly: {
-            title: '是否只读',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.whetherReadOnly',
+              defaultMessage: '是否只读',
+            }),
             required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Radio.Group',
             enum: [
               {
-                label: '是',
+                label: intl.formatMessage({
+                  id: 'pages.device.productDetail.metadata.true',
+                  defaultMessage: '是',
+                }),
                 value: true,
               },
               {
-                label: '否',
+                label: intl.formatMessage({
+                  id: 'pages.device.productDetail.metadata.false',
+                  defaultMessage: '否',
+                }),
                 value: false,
               },
             ],
@@ -279,7 +331,10 @@ const Edit = () => {
           // 存储配置
           configConfig: {
             type: 'void',
-            title: '其他配置',
+            title: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.otherConfiguration',
+              defaultMessage: '其他配置',
+            }),
             'x-visible': false,
             'x-decorator': 'FormItem',
             'x-component': 'ConfigParam',
@@ -289,7 +344,10 @@ const Edit = () => {
       },
 
       description: {
-        title: '描述',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.describe',
+          defaultMessage: '描述',
+        }),
         'x-decorator': 'FormItem',
         'x-component': 'Input.TextArea',
       },
@@ -300,47 +358,71 @@ const Edit = () => {
     type: 'object',
     properties: {
       id: {
-        title: '标识',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.key',
+          defaultMessage: '标识',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       name: {
-        title: '名称',
+        title: intl.formatMessage({
+          id: 'pages.table.name',
+          defaultMessage: '名称',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       async: {
-        title: '是否异步',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.whetherAsync',
+          defaultMessage: '是否异步',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Radio.Group',
         enum: [
           {
-            label: '是',
+            label: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.true',
+              defaultMessage: '是',
+            }),
             value: true,
           },
           {
-            label: '否',
+            label: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.false',
+              defaultMessage: '否',
+            }),
             value: false,
           },
         ],
       },
       inputParams: {
-        title: '输入参数',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.inputParameter',
+          defaultMessage: '输入参数',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       outputParams: {
-        title: '输出参数',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.outputParameters',
+          defaultMessage: '输出参数',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       description: {
-        title: '描述',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.describe',
+          defaultMessage: '描述',
+        }),
         'x-decorator': 'FormItem',
         'x-component': 'Input.TextArea',
       },
@@ -351,19 +433,28 @@ const Edit = () => {
     type: 'object',
     properties: {
       id: {
-        title: '标识',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.key',
+          defaultMessage: '标识',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       name: {
-        title: '名称',
+        title: intl.formatMessage({
+          id: 'pages.table.name',
+          defaultMessage: '名称',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       'expands.level': {
-        title: '级别',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.level',
+          defaultMessage: 'level',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Select',
@@ -376,42 +467,63 @@ const Edit = () => {
     type: 'object',
     properties: {
       id: {
-        title: '标识',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.key',
+          defaultMessage: '标识',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       name: {
-        title: '名称',
+        title: intl.formatMessage({
+          id: 'pages.table.name',
+          defaultMessage: '名称',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Input',
       },
       'valueType.type': {
-        title: '数据类型',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.dataType',
+          defaultMessage: '数据类型',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Select',
         enum: DataTypeList,
       },
       'expands.readOnly': {
-        title: '是否只读',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.whetherReadOnly',
+          defaultMessage: '是否只读',
+        }),
         required: true,
         'x-decorator': 'FormItem',
         'x-component': 'Radio.Group',
         enum: [
           {
-            label: '是',
+            label: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.true',
+              defaultMessage: '是',
+            }),
             value: true,
           },
           {
-            label: '否',
+            label: intl.formatMessage({
+              id: 'pages.device.productDetail.metadata.false',
+              defaultMessage: '否',
+            }),
             value: false,
           },
         ],
       },
       description: {
-        title: '描述',
+        title: intl.formatMessage({
+          id: 'pages.device.productDetail.metadata.describe',
+          defaultMessage: '描述',
+        }),
         'x-decorator': 'FormItem',
         'x-component': 'Input.TextArea',
       },
@@ -458,8 +570,6 @@ const Edit = () => {
     });
   }, [getUnits]);
 
-  const intl = useIntl();
-
   return (
     <Drawer
       width="25vw"
@@ -469,7 +579,7 @@ const Edit = () => {
         defaultMessage: '新增',
       })}-${intl.formatMessage({
         id: `pages.device.metadata.${MetadataModel.type}`,
-        defaultMessage: '',
+        defaultMessage: metadataTypeMapping[MetadataModel.type].name,
       })}`}
       onClose={() => {
         MetadataModel.edit = false;
@@ -485,7 +595,10 @@ const Edit = () => {
             // saveMetadata(type, data);
           }}
         >
-          获取数据
+          {intl.formatMessage({
+            id: 'pages.device.productDetail.metadata.getData',
+            defaultMessage: '获取数据',
+          })}
         </Button>
       }
     >

+ 2 - 2
src/pages/device/Product/Detail/Metadata/index.tsx

@@ -28,7 +28,7 @@ const Metadata = observer(() => {
     >
       <Tabs.TabPane
         tab={intl.formatMessage({
-          id: 'pages.device.productDetail.metadata.attributeDefinition',
+          id: 'pages.device.productDetail.metadata.propertyDefinition',
           defaultMessage: '属性定义',
         })}
         key="properties"
@@ -55,7 +55,7 @@ const Metadata = observer(() => {
       </Tabs.TabPane>
       <Tabs.TabPane
         tab={intl.formatMessage({
-          id: 'pages.device.productDetail.metadata.labelDefinition',
+          id: 'pages.device.productDetail.metadata.tagDefinition',
           defaultMessage: '标签定义',
         })}
         key="tags"