From efe0448498f9d4dc90ff9f37333ad15c52d67aed Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 4 Nov 2023 11:48:41 +0800 Subject: [PATCH 01/14] feat: Add zh-TW locale --- locales/zh-TW.json | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 locales/zh-TW.json diff --git a/locales/zh-TW.json b/locales/zh-TW.json new file mode 100644 index 00000000..d92ccea7 --- /dev/null +++ b/locales/zh-TW.json @@ -0,0 +1,67 @@ +{ + "projectName": { + "message": "請輸入項目名稱:" + }, + "shouldOverwrite": { + "dirForPrompts": { + "current": "目前目錄:", + "target": "目標目錄:" + }, + "message": "非空,是否覆蓋?" + }, + "packageName": { + "message": "請輸入套件名稱:", + "invalidMessage": "無效的 package.json 名稱" + }, + "needsTypeScript": { + "message": "是否使用 TypeScript 語法?" + }, + "needsJsx": { + "message": "是否啟用 JSX 支援?" + }, + "needsRouter": { + "message": "是否引入 Vue Router 進行單頁應用開發?" + }, + "needsPinia": { + "message": "是否引進 Pinia 用於狀態管理?" + }, + "needsVitest": { + "message": "是否引入 Vitest 用於單元測試" + }, + "needsE2eTesting": { + "message": "是否要引入一款端對端(End to End)測試工具?", + "selectOptions": { + "negative": { + "title": "不需要" + }, + "cypress": { + "title": "Cypress", + "desc": "同時支援基於 Cypress Component Testing 的單元測試" + }, + "nightwatch": { + "title": "Nightwatch", + "desc": "同時支援基於 Nightwatch Component Testing 的單元測試" + }, + "playwright": { + "title": "Playwright" + } + } + }, + "needsEslint": { + "message": "是否引入 ESLint 用於程式碼品質檢測?" + }, + "needsPrettier": { + "message": "是否引入 Prettier 用於程式碼格式化?" + }, + "errors": { + "operationCancelled": "操作取消" + }, + "defaultToggleOptions": { + "active": "是", + "inactive": "否" + }, + "infos": { + "scaffolding": "正在建構專案", + "done": "專案建置完成,可執行以下命令:" + } +} From 98a0ad569d9e1b516fdaf6828a7e896ffae6e1cc Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 09:16:12 +0800 Subject: [PATCH 02/14] Update zh-TW.json --- locales/zh-TW.json | 1 + 1 file changed, 1 insertion(+) diff --git a/locales/zh-TW.json b/locales/zh-TW.json index d92ccea7..15c56215 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -30,6 +30,7 @@ }, "needsE2eTesting": { "message": "是否要引入一款端對端(End to End)測試工具?", + "hint": "- 使用箭頭切換按Enter確認。", "selectOptions": { "negative": { "title": "不需要" From b4e937e4fe7df5a4c73e34c7222399965d698e28 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 09:19:45 +0800 Subject: [PATCH 03/14] resolve --- locales/zh-TW.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 15c56215..59be7c91 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -62,7 +62,7 @@ "inactive": "否" }, "infos": { - "scaffolding": "正在建構專案", - "done": "專案建置完成,可執行以下命令:" + "scaffolding": "正在建構項目", + "done": "項目建置完成,可執行以下命令:" } } From 14bf301dcf9aaa4d604dea5392943d97f2b8605d Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 18:33:20 +0800 Subject: [PATCH 04/14] feat: make locales reuseable & add zh-Hant locale --- locales/{zh-TW.json => zh-Hant.json} | 0 utils/getLanguage.ts | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) rename locales/{zh-TW.json => zh-Hant.json} (100%) diff --git a/locales/zh-TW.json b/locales/zh-Hant.json similarity index 100% rename from locales/zh-TW.json rename to locales/zh-Hant.json diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 325cb574..c2d24b53 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -42,6 +42,31 @@ interface Language { } } +/** + * + * This function is used to link obtained locale with correct locale file that could make locales reusable + * + * @param locale the obtained locale + * @returns locale that linked with correct name + */ +function linkLocale(locale: string) { + let linkedLocale: string + switch (locale) { + case 'zh-TW': + linkedLocale = 'zh-Hant' + break + case 'zh-HK': + linkedLocale = 'zh-Hant' + break + case 'zh-MO': + linkedLocale = 'zh-Hant' + default: + linkedLocale = locale + } + + return linkLocale +} + function getLocale() { const shellLocale = Intl.DateTimeFormat().resolvedOptions().locale || // Built-in ECMA-402 support @@ -51,7 +76,7 @@ function getLocale() { // TODO: Windows support if needed, could consider https://www.npmjs.com/package/os-locale 'en-US' // Default fallback - const locale = shellLocale.split('.')[0].replace('_', '-') + const locale = linkLocale(shellLocale.split('.')[0].replace('_', '-')) return locale } From 552d9362702eff1a8ce4136487c42968fbe92b16 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 18:36:41 +0800 Subject: [PATCH 05/14] bugfix --- utils/getLanguage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index c2d24b53..593dad1f 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -44,7 +44,7 @@ interface Language { /** * - * This function is used to link obtained locale with correct locale file that could make locales reusable + * This function is used to link obtained locale with correct locale file in order to make locales reusable * * @param locale the obtained locale * @returns locale that linked with correct name From 7b93c12d330d3222ac41d3cc901e69cb6d2747f3 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 18:41:30 +0800 Subject: [PATCH 06/14] add zh-SG --- locales/{zh-CN.json => zh-Hans.json} | 0 utils/getLanguage.ts | 6 ++++++ 2 files changed, 6 insertions(+) rename locales/{zh-CN.json => zh-Hans.json} (100%) diff --git a/locales/zh-CN.json b/locales/zh-Hans.json similarity index 100% rename from locales/zh-CN.json rename to locales/zh-Hans.json diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 593dad1f..15ab6265 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -60,6 +60,12 @@ function linkLocale(locale: string) { break case 'zh-MO': linkedLocale = 'zh-Hant' + case 'zh-CN': + linkedLocale = 'zh-Hans' + break + case 'zh-SG': + linkedLocale = 'zh-Hans' + break default: linkedLocale = locale } From c20408c07c69d09fafcd56cf8f52e39e27051b5b Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 19:16:16 +0800 Subject: [PATCH 07/14] Apply suggestions from code review Thanks @btea Co-authored-by: btea <2356281422@qq.com> --- utils/getLanguage.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 52cffee1..d44f4737 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -59,8 +59,12 @@ function linkLocale(locale: string) { case 'zh-HK': linkedLocale = 'zh-Hant' break + case 'zh-MO': + case 'zh-TW': + case 'zh-HK': case 'zh-MO': linkedLocale = 'zh-Hant' + break case 'zh-CN': linkedLocale = 'zh-Hans' break @@ -71,7 +75,7 @@ function linkLocale(locale: string) { linkedLocale = locale } - return linkLocale + return linkedLocale } function getLocale() { @@ -83,7 +87,7 @@ function getLocale() { // TODO: Windows support if needed, could consider https://www.npmjs.com/package/os-locale 'en-US' // Default fallback - const locale = linkLocale(shellLocale.split('.')[0].replace('_', '-')) + return linkLocale(shellLocale.split('.')[0].replace('_', '-')) return locale } From 032aa40fafd443c5e4c2620cc361cdf889cbf336 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 19:19:32 +0800 Subject: [PATCH 08/14] improve --- utils/getLanguage.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index d44f4737..138f586e 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -66,8 +66,6 @@ function linkLocale(locale: string) { linkedLocale = 'zh-Hant' break case 'zh-CN': - linkedLocale = 'zh-Hans' - break case 'zh-SG': linkedLocale = 'zh-Hans' break @@ -88,8 +86,6 @@ function getLocale() { 'en-US' // Default fallback return linkLocale(shellLocale.split('.')[0].replace('_', '-')) - - return locale } export default function getLanguage() { @@ -108,9 +104,9 @@ export default function getLanguage() { ) } - const lang: Language = doesLanguageExist - ? require(languageFilePath) - : require(path.resolve(localesRoot, 'en-US.json')) + const lang = ( + doesLanguageExist ? require(languageFilePath) : require(path.resolve(localesRoot, 'en-US.json')) + ) as Language return lang } From 0704cacf2d03ed330483a39e7bb6e0bc50a11996 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 19:21:08 +0800 Subject: [PATCH 09/14] bugfix --- utils/getLanguage.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 138f586e..7dc3a6d2 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -53,12 +53,6 @@ interface Language { function linkLocale(locale: string) { let linkedLocale: string switch (locale) { - case 'zh-TW': - linkedLocale = 'zh-Hant' - break - case 'zh-HK': - linkedLocale = 'zh-Hant' - break case 'zh-MO': case 'zh-TW': case 'zh-HK': From c8bdd6a7f5c04e88eca2ff050ed8adc3626c7bb4 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 11 Nov 2023 22:27:20 +0800 Subject: [PATCH 10/14] delete duplicated case condition --- utils/getLanguage.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index 7dc3a6d2..a17d8375 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -53,7 +53,6 @@ interface Language { function linkLocale(locale: string) { let linkedLocale: string switch (locale) { - case 'zh-MO': case 'zh-TW': case 'zh-HK': case 'zh-MO': From cc427fc8c3a481b82c398cd30ac859aac4b428ff Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 18 Nov 2023 08:23:37 +0800 Subject: [PATCH 11/14] Update locales/zh-Hant.json Co-authored-by: Haoqun Jiang --- locales/zh-Hant.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index 59be7c91..885ac6b3 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -23,7 +23,7 @@ "message": "是否引入 Vue Router 進行單頁應用開發?" }, "needsPinia": { - "message": "是否引進 Pinia 用於狀態管理?" + "message": "是否引入 Pinia 用於狀態管理?" }, "needsVitest": { "message": "是否引入 Vitest 用於單元測試" From 522373d786ca4d82068b9f37342ba51903f4a3c0 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 18 Nov 2023 14:46:37 +0800 Subject: [PATCH 12/14] use correct words --- locales/zh-Hant.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index 885ac6b3..29b72436 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -1,6 +1,6 @@ { "projectName": { - "message": "請輸入項目名稱:" + "message": "請輸入專案名稱:" }, "shouldOverwrite": { "dirForPrompts": { @@ -62,7 +62,7 @@ "inactive": "否" }, "infos": { - "scaffolding": "正在建構項目", - "done": "項目建置完成,可執行以下命令:" + "scaffolding": "正在建構專案", + "done": "專案建置完成,可執行以下命令:" } } From e73a06fad2c075eb7551c6be6a92f65c8b9fb117 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 18 Nov 2023 16:49:57 +0800 Subject: [PATCH 13/14] Apply suggestions from code review Thanks @antfu Co-authored-by: Anthony Fu --- locales/zh-Hant.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index 29b72436..540fd4d1 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -4,8 +4,8 @@ }, "shouldOverwrite": { "dirForPrompts": { - "current": "目前目錄:", - "target": "目標目錄:" + "current": "目前資料夾:", + "target": "目標資料夾:" }, "message": "非空,是否覆蓋?" }, @@ -30,7 +30,7 @@ }, "needsE2eTesting": { "message": "是否要引入一款端對端(End to End)測試工具?", - "hint": "- 使用箭頭切換按Enter確認。", + "hint": "- 使用箭頭切換按 Enter 確認。", "selectOptions": { "negative": { "title": "不需要" From 1127187d41bf50ed802ed7fcfc9c1a9df98b6535 Mon Sep 17 00:00:00 2001 From: CoolPlayLin Date: Sat, 9 Dec 2023 20:34:15 +0800 Subject: [PATCH 14/14] :bug: fix: fix --- locales/zh-Hant.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/zh-Hant.json b/locales/zh-Hant.json index 540fd4d1..e1901ed3 100644 --- a/locales/zh-Hant.json +++ b/locales/zh-Hant.json @@ -4,7 +4,7 @@ }, "shouldOverwrite": { "dirForPrompts": { - "current": "目前資料夾:", + "current": "當前資料夾", "target": "目標資料夾:" }, "message": "非空,是否覆蓋?" @@ -62,7 +62,7 @@ "inactive": "否" }, "infos": { - "scaffolding": "正在建構專案", + "scaffolding": "正在建置專案", "done": "專案建置完成,可執行以下命令:" } }