diff --git a/ali-dbhub-client/src/components/Setting/index.tsx b/ali-dbhub-client/src/components/Setting/index.tsx
index 56c448421..65170d349 100644
--- a/ali-dbhub-client/src/components/Setting/index.tsx
+++ b/ali-dbhub-client/src/components/Setting/index.tsx
@@ -3,7 +3,7 @@ import styles from './index.less';
import classnames from 'classnames';
import Iconfont from '@/components/Iconfont';
import Button from '@/components/Button';
-import { Modal, Radio, Input, message, Select, Tooltip } from 'antd';
+import { Modal, Radio, Input, message, Select, Tooltip, RadioChangeEvent } from 'antd';
import i18n from '@/i18n';
import { imghub } from '@/utils/imghub';
import configService, { IChatgptConfig } from '@/service/config';
@@ -320,9 +320,10 @@ export function BaseBody() {
setCurrentPrimaryColor(item.code)
};
- function changeLang() {
- const lang = localStorage.getItem('lang') === 'en' ? 'zh-cn' : 'en'
- localStorage.setItem('lang', lang);
+ function changeLang(e: RadioChangeEvent) {
+
+ // const lang = localStorage.getItem('lang') === 'en' ? 'zh-cn' : 'en'
+ localStorage.setItem('lang', e.target.value);
location.reload();
}
@@ -346,6 +347,7 @@ export function BaseBody() {
{i18n('common.text.zh-cn')}
+ {i18n('common.text.zh-tw')}
{i18n('common.text.en')}
diff --git a/ali-dbhub-client/src/i18n/en.ts b/ali-dbhub-client/src/i18n/en.ts
index 544cd4210..03134193f 100644
--- a/ali-dbhub-client/src/i18n/en.ts
+++ b/ali-dbhub-client/src/i18n/en.ts
@@ -1,5 +1,5 @@
export default {
- lang:'em',
+ lang: 'em',
'common.data.hour': '{1} {hour|hours}',
'common.data.minute': '{1} {minute|minutes}',
@@ -21,6 +21,7 @@ export default {
'common.text.language': 'language',
'common.text.en': 'en',
'common.text.zh-cn': 'zh-cn',
+ 'common.text.zh-tw': 'zh-tw',
'home.nav.database': 'Database',
'home.nav.myHistory': 'My History',
@@ -30,7 +31,7 @@ export default {
'history.title.myHistory': 'My History',
'history.tab.mySave': 'My Save',
'history.tab.executionHistory': 'Execution History',
-
+
'home.title.name': 'database',
'home.title.link': 'link',
@@ -43,4 +44,4 @@ export default {
'connection.button.edit': 'edit',
'connection.button.clone': 'clone',
'connection.button.delete': 'delete',
-}
\ No newline at end of file
+}
diff --git a/ali-dbhub-client/src/i18n/index.tsx b/ali-dbhub-client/src/i18n/index.tsx
index 200bb38ef..74ddbaa53 100644
--- a/ali-dbhub-client/src/i18n/index.tsx
+++ b/ali-dbhub-client/src/i18n/index.tsx
@@ -1,21 +1,24 @@
import zhCN from './zh-cn';
+import zhTW from './zh-tw';
import en from './en';
import React, { Fragment } from 'react';
-const locale = {
- en,
+const locale: { [key: string]: any } = {
+ 'en': en,
'zh-cn': zhCN,
+ 'zh-tw': zhTW
};
const _isEN = (localStorage.getItem('lang') || '').toLowerCase().indexOf('en') > -1;
export function isEN() {
return _isEN;
}
-const langSet:any = locale[_isEN ? 'en' : 'zh-cn'];
-
+const storageLang = localStorage.getItem('lang') ?? 'zh-cn';
+const langSet: any = locale[storageLang];
export type I18nKey = keyof typeof zhCN;
function i18n(key: keyof typeof zhCN, ...args: any[]): string;
function i18n(key: string, ...args: any[]) {
+ console.log(storageLang);
let result: string = langSet[key];
if (result === undefined) {
return `[${key}]`;
diff --git a/ali-dbhub-client/src/i18n/zh-cn.ts b/ali-dbhub-client/src/i18n/zh-cn.ts
index c3d881bbe..7bbcfd2cf 100644
--- a/ali-dbhub-client/src/i18n/zh-cn.ts
+++ b/ali-dbhub-client/src/i18n/zh-cn.ts
@@ -21,6 +21,7 @@ export default {
'common.text.language': '语言',
'common.text.en': '英文',
'common.text.zh-cn': '中文',
+ 'common.text.zh-tw': '繁體中文',
'home.nav.database': '连接管理',
'home.nav.myHistory': '历史记录',
@@ -41,5 +42,5 @@ export default {
'connection.input.newLink': '新建连接',
'connection.button.edit': '修改连接',
'connection.button.clone': '克隆连接',
- 'connection.button.delete': '删除连接'
-}
\ No newline at end of file
+ 'connection.button.delete': '删除连接'
+}
diff --git a/ali-dbhub-client/src/i18n/zh-tw.ts b/ali-dbhub-client/src/i18n/zh-tw.ts
new file mode 100644
index 000000000..39efe7921
--- /dev/null
+++ b/ali-dbhub-client/src/i18n/zh-tw.ts
@@ -0,0 +1,46 @@
+export default {
+ lang: 'zh-tw',
+
+ 'common.data.hour': '{1}小時',
+ 'common.data.minute': '{1}分鐘',
+ 'common.tip.yesterday': '昨天{1}',
+ 'common.tip.tomorrow': '明天{1}',
+ 'common.tip.ago': '前',
+ 'common.tip.later': '後',
+ 'common.tip.now': '現在',
+ 'common.tip.justNow': '剛剛',
+ 'common.text.search': '搜尋',
+ 'common.placeholder.select': '請選擇{1}',
+ 'common.text.serviceStarting': '服務啟動中...',
+ 'common.text.serviceFail': '服務啟動失敗',
+ 'common.text.column': '列',
+ 'common.text.indexes': '索引',
+ 'common.button.save': '保存',
+ 'common.button.execute': '執行',
+ 'common.text.background': '背景',
+ 'common.text.language': '語言',
+ 'common.text.en': '英文',
+ 'common.text.zh-cn': '中文',
+ 'common.text.zh-tw': '繁體中文',
+
+ 'home.nav.database': '連線管理',
+ 'home.nav.myHistory': '歷史紀錄',
+ 'home.nav.github': 'GitHub',
+ 'home.text.visitedTime': '最近訪問時間:',
+
+ 'history.title.myHistory': '我的SQL',
+ 'history.tab.mySave': '我的保存',
+ 'history.tab.executionHistory': '執行紀錄',
+
+ 'home.title.name': '資料庫',
+ 'home.title.link': '連線',
+ 'home.title.setting': '設定',
+ 'home.title.query': '查詢',
+
+ 'connection.buttonn.colorSwitch': '顏色切換',
+ 'connection.button.overview': '連線概覽',
+ 'connection.input.newLink': '新建連線',
+ 'connection.button.edit': '修改連線',
+ 'connection.button.clone': '複製連線',
+ 'connection.button.delete': '刪除連線'
+}