From: btea <2356281422@qq.com> Date: Thu, 29 Feb 2024 12:23:39 +0000 (+0800) Subject: feat: use `Intl.getCanonicalLocales` check locale (#450) X-Git-Tag: v3.10.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2195946f76832710c4fceb47c64e6c747cbed83d;p=thirdparty%2Fvuejs%2Fcreate-vue.git feat: use `Intl.getCanonicalLocales` check locale (#450) --- diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index b0de77bd..6b853c3b 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -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':