Skip to content

Commit

Permalink
Add Traditional Chinese language locale for UI
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Mar 6, 2023
1 parent de34d97 commit e9785e8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/common/Setting/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const themeOptions: { label: string; key: Theme; icon: string }[] = [
const languageOptions: { label: string; key: Language; value: Language }[] = [
{ label: '中文', key: 'zh-CN', value: 'zh-CN' },
{ label: '繁體中文', key: 'zh-TW', value: 'zh-TW' },
{ label: 'English', key: 'en-US', value: 'en-US' },
]
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed } from 'vue'
import { enUS, zhCN } from 'naive-ui'
import { enUS, zhCN, zhTW } from 'naive-ui'
import { useAppStore } from '@/store'
import { setLocale } from '@/locales'

Expand All @@ -14,6 +14,9 @@ export function useLanguage() {
case 'zh-CN':
setLocale('zh-CN')
return zhCN
case 'zh-TW':
setLocale('zh-TW')
return zhTW
default:
setLocale('zh-CN')
return enUS
Expand Down
2 changes: 2 additions & 0 deletions src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { App } from 'vue'
import { createI18n } from 'vue-i18n'
import en from './en-US'
import cn from './zh-CN'
import tw from './zh-TW'
import { useAppStoreWithOut } from '@/store/modules/app'
import type { Language } from '@/store/modules/app/helper'

Expand All @@ -16,6 +17,7 @@ const i18n = createI18n({
messages: {
'en-US': en,
'zh-CN': cn,
'zh-TW': tw,
},
})

Expand Down
40 changes: 40 additions & 0 deletions src/locales/zh-TW.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export default {
common: {
delete: '刪除',
save: '儲存',
reset: '重設',
yes: '是',
no: '否',
noData: '暫無資料',
wrong: '好像出錯了,請稍後再試。',
success: '操作成功',
failed: '操作失敗',
},
chat: {
placeholder: '來講點什麼...(Shift + Enter = 換行)',
placeholderMobile: '來講點什麼...',
copy: '複製',
copied: '複製成功',
copyCode: '複製代碼',
clearChat: '清空對話',
clearChatConfirm: '是否清空對話?',
deleteMessage: '刪除訊息',
deleteMessageConfirm: '是否刪除此訊息?',
deleteHistoryConfirm: '確定刪除此紀錄?',
},
setting: {
setting: '設定',
general: '總覽',
config: '配置',
avatarLink: '頭像連結',
name: '名稱',
description: '描述',
resetUserInfo: '重設使用者資訊',
theme: '主題',
language: '語言',
api: 'API',
reverseProxy: '反向代理',
timeout: '逾時',
socks: 'Socks',
},
}
2 changes: 1 addition & 1 deletion src/store/modules/app/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const LOCAL_NAME = 'appSetting'

export type Theme = 'light' | 'dark' | 'auto'

export type Language = 'zh-CN' | 'en-US'
export type Language = 'zh-CN' | 'zh-TW' | 'en-US'

export interface AppState {
siderCollapsed: boolean
Expand Down

0 comments on commit e9785e8

Please sign in to comment.