]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
feat: use `Intl.getCanonicalLocales` check locale (#450)
authorbtea <2356281422@qq.com>
Thu, 29 Feb 2024 12:23:39 +0000 (20:23 +0800)
committerGitHub <noreply@github.com>
Thu, 29 Feb 2024 12:23:39 +0000 (20:23 +0800)
utils/getLanguage.ts

index b0de77bd12dd8eb0ae4b425df63b413b666e5396..6b853c3b8f08c91b259e79e8acc2ce569c64670d 100644 (file)
@@ -52,7 +52,13 @@ interface Language {
  */
 function linkLocale(locale: string) {
   let linkedLocale: string
-  switch (locale) {
+  try {
+    // @ts-ignore
+    linkedLocale = Intl.getCanonicalLocales(locale)[0]
+  } catch (error) {
+    console.log(`${error.toString()}\n`)
+  }
+  switch (linkedLocale) {
     case 'zh-TW':
     case 'zh-HK':
     case 'zh-MO':