File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,13 @@ function normalizeLocale (locale: string | null) {
1212 if ( ! locale )
1313 return undefined ;
1414 try {
15- locale = locale . toLocaleLowerCase ( ) ;
16- if ( locale . includes ( "zh" ) ) {
17- // browser does not recognize "zh-chs" and "zh-cht" as equivalents of "zh-HANS " "zh-HANT ", we are helping, otherwise
15+ locale = locale . toLocaleLowerCase ( ) . replace ( "_" , "-" ) ;
16+ if ( locale . startsWith ( "zh- " ) ) {
17+ // browser does not recognize "zh-chs" and "zh-cht" as equivalents of "zh-Hans " "zh-Hant ", we are helping, otherwise
1818 // it would throw on getCanonicalLocales with "RangeError: Incorrect locale information provided"
19- locale = locale . replace ( "chs" , "HANS " ) . replace ( "cht" , "HANT " ) ;
19+ locale = locale . replace ( "- chs" , "-Hans " ) . replace ( "- cht" , "-Hant " ) ;
2020 }
21- const canonicalLocales = ( Intl as any ) . getCanonicalLocales ( locale . replace ( "_" , "-" ) ) ;
21+ const canonicalLocales = ( Intl as any ) . getCanonicalLocales ( locale ) ;
2222 return canonicalLocales . length > 0 ? canonicalLocales [ 0 ] : undefined ;
2323 } catch {
2424 return undefined ;
You can’t perform that action at this time.
0 commit comments