You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by kr...@apache.org on 2022/11/08 23:45:29 UTC

[incubator-streampark] branch dev updated: Add i18n support for token menu. (#1990)

This is an automated email from the ASF dual-hosted git repository.

kriszu pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new d83d4e3a6 Add i18n support for token menu. (#1990)
d83d4e3a6 is described below

commit d83d4e3a6333f38cdff32dd5ba4a58c04ca3af66
Author: lvlin241 <lv...@163.com>
AuthorDate: Wed Nov 9 07:45:21 2022 +0800

    Add i18n support for token menu. (#1990)
---
 .../src/locales/lang/en/system/token.ts            | 40 ++++++++++++++++++++++
 .../src/locales/lang/zh-CN/system/token.ts         | 40 ++++++++++++++++++++++
 .../src/views/system/token/Token.vue               | 20 +++++------
 .../views/system/token/components/TokenDrawer.vue  |  4 ++-
 .../src/views/system/token/token.data.ts           | 30 ++++++++--------
 5 files changed, 109 insertions(+), 25 deletions(-)

diff --git a/streampark-console/streampark-console-newui/src/locales/lang/en/system/token.ts b/streampark-console/streampark-console-newui/src/locales/lang/en/system/token.ts
new file mode 100644
index 000000000..af27ea1d6
--- /dev/null
+++ b/streampark-console/streampark-console-newui/src/locales/lang/en/system/token.ts
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+  addToken: 'Add Token',
+  modifyToken: 'Edit Token',
+  copyToken: 'Copy Token',
+  deleteToken: 'Delete Token',
+  selectUserAlertMessage: 'Please select a user',
+  table: {
+    title: 'Token List',
+    userName: 'User Name',
+    token: 'Token',
+    description: 'Description',
+    createTime: 'Create Time',
+    expireTime: 'Expire Time',
+    status: 'Status'
+  },
+  operation: {
+    copySuccess: 'copy success',
+    deleteTokenConfirm: 'are you sure delete this token ?',
+    deleteSuccess: 'delete token successfully',
+    deleteFailed: 'delete token failed',
+    updateSuccess: 'update token successfully',
+    createSuccess: 'create token successfully',
+  }
+}
diff --git a/streampark-console/streampark-console-newui/src/locales/lang/zh-CN/system/token.ts b/streampark-console/streampark-console-newui/src/locales/lang/zh-CN/system/token.ts
new file mode 100644
index 000000000..404406e3b
--- /dev/null
+++ b/streampark-console/streampark-console-newui/src/locales/lang/zh-CN/system/token.ts
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+  addToken: '新增Token',
+  modifyToken: '编辑Token',
+  copyToken: '复制Token',
+  deleteToken: '删除Token',
+  selectUserAlertMessage: '请选择一个用户',
+  table: {
+    title: 'Token 列表',
+    userName: '用户名',
+    token: 'Token',
+    description: '描述',
+    createTime: '创建时间',
+    expireTime: '过期时间',
+    status: '状态'
+  },
+  operation: {
+    copySuccess: '复制成功',
+    deleteTokenConfirm: '您确定删除该token ?',
+    deleteSuccess: '删除成功',
+    deleteFailed: '删除失败',
+    updateSuccess: '更新成功',
+    createSuccess: '创建成功',
+  }
+}
diff --git a/streampark-console/streampark-console-newui/src/views/system/token/Token.vue b/streampark-console/streampark-console-newui/src/views/system/token/Token.vue
index 85fa51864..81f71e95b 100644
--- a/streampark-console/streampark-console-newui/src/views/system/token/Token.vue
+++ b/streampark-console/streampark-console-newui/src/views/system/token/Token.vue
@@ -29,7 +29,7 @@
             :actions="[
               {
                 icon: 'ant-design:copy-outlined',
-                tooltip: 'Copy Token',
+                tooltip: t('system.token.copyToken'),
                 auth: 'token:view',
                 onClick: handleCopy.bind(null, record),
               },
@@ -37,9 +37,9 @@
                 icon: 'ant-design:delete-outlined',
                 color: 'error',
                 auth: 'token:delete',
-                tooltip: 'Delete Token',
+                tooltip: t('system.token.deleteToken'),
                 popConfirm: {
-                  title: 'are you sure delete this token ?',
+                  title: t('system.token.operation.deleteTokenConfirm'),
                   confirm: handleDelete.bind(null, record),
                 },
               },
@@ -73,7 +73,7 @@
       const [registerDrawer, { openDrawer }] = useDrawer();
       const { clipboardRef, copiedRef } = useCopyToClipboard();
       const [registerTable, { reload, updateTableDataRecord }] = useTable({
-        title: 'Token List',
+        title: t('system.token.table.title'),
         api: fetTokenList,
         columns,
         formConfig: {
@@ -88,7 +88,7 @@
         canResize: false,
         actionColumn: {
           width: 200,
-          title: 'Operation',
+          title: t('component.table.operation'),
           dataIndex: 'action',
         },
       });
@@ -101,25 +101,25 @@
 
       function handleCopy(record: Recordable) {
         clipboardRef.value = record.token;
-        unref(copiedRef) && createMessage.success('copy success!');
+        unref(copiedRef) && createMessage.success(t('system.token.operation.copySuccess'));
       }
 
       async function handleDelete(record: Recordable) {
         const res = await fetchTokenDelete({ tokenId: record.id });
         if (res) {
-          createMessage.success('delete token successfully');
+          createMessage.success(t('system.token.operation.deleteSuccess'));
           reload();
         } else {
-          createMessage.success('delete token failed');
+          createMessage.success(t('system.token.operation.deleteFailed'));
         }
       }
 
       function handleSuccess({ isUpdate, values }) {
         if (isUpdate) {
-          createMessage.success('update token successfully');
+          createMessage.success(t('system.token.operation.updateSuccess'));
           updateTableDataRecord(values.tokenId, values);
         } else {
-          createMessage.success('create token successfully');
+          createMessage.success(t('system.token.operation.createSuccess'));
           reload();
         }
       }
diff --git a/streampark-console/streampark-console-newui/src/views/system/token/components/TokenDrawer.vue b/streampark-console/streampark-console-newui/src/views/system/token/components/TokenDrawer.vue
index 2cb54c256..5b1699955 100644
--- a/streampark-console/streampark-console-newui/src/views/system/token/components/TokenDrawer.vue
+++ b/streampark-console/streampark-console-newui/src/views/system/token/components/TokenDrawer.vue
@@ -33,6 +33,7 @@
   import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
 
   import { fetchTokenCreate } from '/@/api/system/token';
+  import { useI18n } from '/@/hooks/web/useI18n';
 
   export default defineComponent({
     name: 'TokenDrawer',
@@ -40,6 +41,7 @@
     emits: ['success', 'register'],
     setup(_, { emit }) {
       const isUpdate = ref(true);
+      const { t } = useI18n();
 
       const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
         labelWidth: 120,
@@ -60,7 +62,7 @@
         }
       });
 
-      const getTitle = computed(() => (!unref(isUpdate) ? 'Add Token' : 'Edit Token'));
+      const getTitle = computed(() => (!unref(isUpdate) ? t('system.token.addToken') : t('system.token.modifyToken')));
 
       async function handleSubmit() {
         try {
diff --git a/streampark-console/streampark-console-newui/src/views/system/token/token.data.ts b/streampark-console/streampark-console-newui/src/views/system/token/token.data.ts
index 85b4247b6..58ea1a7ca 100644
--- a/streampark-console/streampark-console-newui/src/views/system/token/token.data.ts
+++ b/streampark-console/streampark-console-newui/src/views/system/token/token.data.ts
@@ -21,6 +21,8 @@ import { useMessage } from '/@/hooks/web/useMessage';
 import { fetTokenStatusToggle } from '/@/api/system/token';
 import { getNoTokenUserList } from '/@/api/system/user';
 import dayjs from 'dayjs';
+import {useI18n} from "/@/hooks/web/useI18n";
+const { t } = useI18n();
 
 // status enum
 const enum StatusEnum {
@@ -30,32 +32,32 @@ const enum StatusEnum {
 
 export const columns: BasicColumn[] = [
   {
-    title: 'User Name',
+    title: t('system.token.table.userName'),
     dataIndex: 'username',
     width: 150,
     sorter: true,
   },
   {
-    title: 'Token',
+    title: t('system.token.table.token'),
     ellipsis: true,
     width: 250,
     dataIndex: 'token',
   },
   {
-    title: 'Description',
+    title: t('system.token.table.description'),
     dataIndex: 'description',
   },
   {
-    title: 'Create Time',
+    title: t('system.token.table.createTime'),
     dataIndex: 'createTime',
   },
   {
-    title: 'Expire Time',
+    title: t('system.token.table.expireTime'),
     dataIndex: 'expireTime',
     sorter: true,
   },
   {
-    title: 'Status',
+    title: t('system.token.table.status'),
     dataIndex: 'userStatus',
     width: 100,
     customRender: ({ record }) => {
@@ -88,8 +90,8 @@ export const columns: BasicColumn[] = [
 
 export const searchFormSchema: FormSchema[] = [
   {
-    field: 'username',
-    label: 'User Name',
+    field: t('system.token.table.userName'),
+    label: t('system.token.table.userName'),
     component: 'Input',
     colProps: { span: 8 },
   },
@@ -98,7 +100,7 @@ export const searchFormSchema: FormSchema[] = [
 export const formSchema: FormSchema[] = [
   {
     field: 'userId',
-    label: 'User',
+    label: t('system.token.table.userName'),
     component: 'ApiSelect',
     componentProps: {
       api: getNoTokenUserList,
@@ -106,16 +108,16 @@ export const formSchema: FormSchema[] = [
       labelField: 'username',
       valueField: 'userId',
     },
-    rules: [{ required: true, message: 'Please select a user', trigger: 'blur' }],
+    rules: [{ required: true, message: t('system.token.selectUserAlertMessage'), trigger: 'blur' }],
   },
   {
-    field: 'description',
-    label: 'Description',
+    field: t('system.token.table.description'),
+    label: t('system.token.table.description'),
     component: 'InputTextArea',
   },
   {
-    field: 'expireTime',
-    label: 'ExpireTime',
+    field: t('system.token.table.expireTime'),
+    label: t('system.token.table.expireTime'),
     component: 'DatePicker',
     defaultValue: dayjs('9999-01-01'),
     componentProps: {