Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit df50c11

Browse files
haoqunjiangcexbrayat
authored andcommitted
fix: don't show error when locale is C/C.UTF-8
1 parent 3642c1c commit df50c11

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎utils/getLanguage.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ interface Language {
5151
* @returns locale that linked with correct name
5252
*/
5353
function linkLocale(locale: string) {
54+
// The C locale is the default system locale for POSIX systems.
55+
// https://docs.oracle.com/cd/E36784_01/html/E36823/glmar.html
56+
// https://sourceware.org/glibc/wiki/Proposals/C.UTF-8
57+
// It is common among containerized environments or minimal virtual environments
58+
// though most user-facing systems would have a more specific locale set.
59+
// The problem here is that the C locale is not a valid language tag for the Intl API.
60+
// But it is not desirable to throw an error in this case.
61+
// So we map it to 'en-US'.
62+
if (locale === 'C') {
63+
return 'en-US'
64+
}
65+
5466
let linkedLocale: string
5567
try {
5668
linkedLocale = Intl.getCanonicalLocales(locale)[0]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /