Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Traditional Chinese language locale for UI #348

Merged
merged 2 commits into from
Mar 7, 2023
Merged
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
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
10 changes: 6 additions & 4 deletions src/locales/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { App } from 'vue'
import { createI18n } from 'vue-i18n'
import en from './en-US'
import cn from './zh-CN'
import enUS from './en-US'
import zhCN from './zh-CN'
import zhTW from './zh-TW'
import { useAppStoreWithOut } from '@/store/modules/app'
import type { Language } from '@/store/modules/app/helper'

Expand All @@ -14,8 +15,9 @@ const i18n = createI18n({
fallbackLocale: 'en-US',
allowComposition: true,
messages: {
'en-US': en,
'zh-CN': cn,
'en-US': enUS,
'zh-CN': zhCN,
'zh-TW': zhTW,
},
})

Expand Down
43 changes: 43 additions & 0 deletions src/locales/zh-TW.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export default {
common: {
delete: '刪除',
save: '儲存',
reset: '重設',
export: '導出',
import: '導入',
clear: '清空',
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