-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Add Traditional Chinese support and skip Google Antigravity #18
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |||||||||||||||||||||||||||||||||||||
| // 类型定义 | ||||||||||||||||||||||||||||||||||||||
| // ============================================================================ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export type Language = "zh" | "en"; | ||||||||||||||||||||||||||||||||||||||
| export type Language = "zh" | "zh-tw" | "en"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // ============================================================================ | ||||||||||||||||||||||||||||||||||||||
| // 语言检测 | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -25,6 +25,7 @@ function detectLanguage(): Language { | |||||||||||||||||||||||||||||||||||||
| // 1. 优先使用 Intl API(更可靠) | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| const intlLocale = Intl.DateTimeFormat().resolvedOptions().locale; | ||||||||||||||||||||||||||||||||||||||
| if (intlLocale.startsWith("zh-TW") || intlLocale.startsWith("zh-Hant")) return "zh-tw"; | ||||||||||||||||||||||||||||||||||||||
| if (intlLocale.startsWith("zh")) return "zh"; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
29
|
||||||||||||||||||||||||||||||||||||||
| if (intlLocale.startsWith("zh-TW") || intlLocale.startsWith("zh-Hant")) return "zh-tw"; | |
| if (intlLocale.startsWith("zh")) return "zh"; | |
| // 规范化 locale(将下划线替换为连字符),并解析 BCP 47 子标签 | |
| const normalizedLocale = intlLocale.replace(/_/g, "-"); | |
| const parts = normalizedLocale.split("-"); | |
| const baseLang = parts[0]?.toLowerCase(); | |
| if (baseLang === "zh") { | |
| const subtags = parts.slice(1).map((p) => p.toLowerCase()); | |
| // 传统中文:脚本为 Hant 或地区为 TW/HK | |
| if ( | |
| subtags.includes("hant") || | |
| subtags.includes("tw") || | |
| subtags.includes("hk") | |
| ) { | |
| return "zh-tw"; | |
| } | |
| return "zh"; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
"zh-tw"toLanguagemeans any existingcurrentLang === "zh" ? ... : ...branches will now incorrectly treat Traditional Chinese users as non-Chinese (e.g.,plugin/lib/google.tsreturns English "reset" forzh-tw). Please audit/update those conditionals (or centralize via a helper like “isChinese”) sozh-twgets the intended Chinese output.