mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-29 23:24:25 +02:00
Improve i18n language matching (#5939)
Some checks are pending
Auto Test / auto-test (18, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (18, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, windows-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (20, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, windows-latest) (push) Blocked by required conditions
Auto Test / armv7-simple-test (18, ARMv7) (push) Waiting to run
Auto Test / armv7-simple-test (20, ARMv7) (push) Waiting to run
Auto Test / check-linters (push) Waiting to run
Auto Test / e2e-test (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
validate / json-yaml-validate (push) Waiting to run
validate / validate (push) Waiting to run
Some checks are pending
Auto Test / auto-test (18, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (18, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, windows-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (20, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, windows-latest) (push) Blocked by required conditions
Auto Test / armv7-simple-test (18, ARMv7) (push) Waiting to run
Auto Test / armv7-simple-test (20, ARMv7) (push) Waiting to run
Auto Test / check-linters (push) Waiting to run
Auto Test / e2e-test (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
validate / json-yaml-validate (push) Waiting to run
validate / validate (push) Waiting to run
This commit is contained in:
parent
5aeda2dab0
commit
072226bde2
1 changed files with 14 additions and 5 deletions
13
src/i18n.js
13
src/i18n.js
|
@ -75,13 +75,22 @@ export function currentLocale() {
|
||||||
if (locale in messages) {
|
if (locale in messages) {
|
||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
// some locales are further specified such as "en-US".
|
// If the locale is a 2-letter code, we can try to find a regional variant
|
||||||
|
// e.g. "fr" may not be in the messages, but "fr-FR" is
|
||||||
|
if (locale.length === 2) {
|
||||||
|
const regionalLocale = `${locale}-${locale.toUpperCase()}`;
|
||||||
|
if (regionalLocale in messages) {
|
||||||
|
return regionalLocale;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Some locales are further specified such as "en-US".
|
||||||
// If we only have a generic locale for this, we can use it too
|
// If we only have a generic locale for this, we can use it too
|
||||||
const genericLocale = locale.split("-")[0];
|
const genericLocale = locale.slice(0, 2);
|
||||||
if (genericLocale in messages) {
|
if (genericLocale in messages) {
|
||||||
return genericLocale;
|
return genericLocale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return "en";
|
return "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue