Skip to content

Commit 2195946

Browse files
authoredFeb 29, 2024
feat: use Intl.getCanonicalLocales check locale (#450)
1 parent 1563eb9 commit 2195946

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎utils/getLanguage.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ interface Language {
5252
*/
5353
function linkLocale(locale: string) {
5454
let linkedLocale: string
55-
switch (locale) {
55+
try {
56+
// @ts-ignore
57+
linkedLocale = Intl.getCanonicalLocales(locale)[0]
58+
} catch (error) {
59+
console.log(`${error.toString()}\n`)
60+
}
61+
switch (linkedLocale) {
5662
case 'zh-TW':
5763
case 'zh-HK':
5864
case 'zh-MO':

0 commit comments

Comments
 (0)
Failed to load comments.