Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Add Traditional Chinese #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ali-dbhub-client/src/components/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}

Expand All @@ -346,6 +347,7 @@ export function BaseBody() {
<div>
<Radio.Group onChange={changeLang} value={lang}>
<Radio value='zh-cn'>{i18n('common.text.zh-cn')}</Radio>
<Radio value='zh-tw'>{i18n('common.text.zh-tw')}</Radio>
<Radio value='en'>{i18n('common.text.en')}</Radio>
</Radio.Group>
</div>
Expand Down
7 changes: 4 additions & 3 deletions ali-dbhub-client/src/i18n/en.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
lang:'em',
lang: 'em',

'common.data.hour': '{1} {hour|hours}',
'common.data.minute': '{1} {minute|minutes}',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -43,4 +44,4 @@ export default {
'connection.button.edit': 'edit',
'connection.button.clone': 'clone',
'connection.button.delete': 'delete',
}
}
11 changes: 7 additions & 4 deletions ali-dbhub-client/src/i18n/index.tsx
Original file line number Diff line number Diff line change
@@ -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}]`;
Expand Down
5 changes: 3 additions & 2 deletions ali-dbhub-client/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '历史记录',
Expand All @@ -41,5 +42,5 @@ export default {
'connection.input.newLink': '新建连接',
'connection.button.edit': '修改连接',
'connection.button.clone': '克隆连接',
'connection.button.delete': '删除连接'
}
'connection.button.delete': '删除连接'
}
46 changes: 46 additions & 0 deletions ali-dbhub-client/src/i18n/zh-tw.ts
Original file line number Diff line number Diff line change
@@ -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': '刪除連線'
}