Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f68aaa

Browse files
CoolPlayLinbteahaoqunjiangantfu
authored
feat: make locales reusable & add zh-Hant locale (#365)
Co-authored-by: btea <2356281422@qq.com> Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com> Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent 6a16968 commit 5f68aaa

File tree

3 files changed

+95
-3
lines changed

3 files changed

+95
-3
lines changed
File renamed without changes.

‎locales/zh-Hant.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"projectName": {
3+
"message": "請輸入專案名稱:"
4+
},
5+
"shouldOverwrite": {
6+
"dirForPrompts": {
7+
"current": "當前資料夾",
8+
"target": "目標資料夾:"
9+
},
10+
"message": "非空,是否覆蓋?"
11+
},
12+
"packageName": {
13+
"message": "請輸入套件名稱:",
14+
"invalidMessage": "無效的 package.json 名稱"
15+
},
16+
"needsTypeScript": {
17+
"message": "是否使用 TypeScript 語法?"
18+
},
19+
"needsJsx": {
20+
"message": "是否啟用 JSX 支援?"
21+
},
22+
"needsRouter": {
23+
"message": "是否引入 Vue Router 進行單頁應用開發?"
24+
},
25+
"needsPinia": {
26+
"message": "是否引入 Pinia 用於狀態管理?"
27+
},
28+
"needsVitest": {
29+
"message": "是否引入 Vitest 用於單元測試"
30+
},
31+
"needsE2eTesting": {
32+
"message": "是否要引入一款端對端(End to End)測試工具?",
33+
"hint": "- 使用箭頭切換按 Enter 確認。",
34+
"selectOptions": {
35+
"negative": {
36+
"title": "不需要"
37+
},
38+
"cypress": {
39+
"title": "Cypress",
40+
"desc": "同時支援基於 Cypress Component Testing 的單元測試"
41+
},
42+
"nightwatch": {
43+
"title": "Nightwatch",
44+
"desc": "同時支援基於 Nightwatch Component Testing 的單元測試"
45+
},
46+
"playwright": {
47+
"title": "Playwright"
48+
}
49+
}
50+
},
51+
"needsEslint": {
52+
"message": "是否引入 ESLint 用於程式碼品質檢測?"
53+
},
54+
"needsPrettier": {
55+
"message": "是否引入 Prettier 用於程式碼格式化?"
56+
},
57+
"errors": {
58+
"operationCancelled": "操作取消"
59+
},
60+
"defaultToggleOptions": {
61+
"active": "",
62+
"inactive": ""
63+
},
64+
"infos": {
65+
"scaffolding": "正在建置專案",
66+
"done": "專案建置完成,可執行以下命令:"
67+
}
68+
}

‎utils/getLanguage.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ interface Language {
4343
}
4444
}
4545

46+
/**
47+
*
48+
* This function is used to link obtained locale with correct locale file in order to make locales reusable
49+
*
50+
* @param locale the obtained locale
51+
* @returns locale that linked with correct name
52+
*/
53+
function linkLocale(locale: string) {
54+
let linkedLocale: string
55+
switch (locale) {
56+
case 'zh-TW':
57+
case 'zh-HK':
58+
case 'zh-MO':
59+
linkedLocale = 'zh-Hant'
60+
break
61+
case 'zh-CN':
62+
case 'zh-SG':
63+
linkedLocale = 'zh-Hans'
64+
break
65+
default:
66+
linkedLocale = locale
67+
}
68+
69+
return linkedLocale
70+
}
71+
4672
function getLocale() {
4773
const shellLocale =
4874
process.env.LC_ALL || // POSIX locale environment variables
@@ -51,9 +77,7 @@ function getLocale() {
5177
Intl.DateTimeFormat().resolvedOptions().locale || // Built-in ECMA-402 support
5278
'en-US' // Default fallback
5379

54-
const locale = shellLocale.split('.')[0].replace('_', '-')
55-
56-
return locale
80+
return linkLocale(shellLocale.split('.')[0].replace('_', '-'))
5781
}
5882

5983
export default function getLanguage() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /