1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 22:39:18 +01:00

Improve i18n support, close #2417 (#2418)

This commit is contained in:
Peter Dave Hello
2023-10-16 07:45:53 +08:00
committed by GitHub
parent 59c72f91ce
commit 55775f651f

View File

@@ -7,9 +7,15 @@ const messages = Object.fromEntries(
return [key.slice(14, yaml ? -5 : -4), value.default];
}),
);
const userLang = navigator.language;
const shortLang = userLang.slice(0, 2);
const locale = messages.hasOwnProperty(userLang) ? userLang : shortLang;
const i18n = createI18n({
legacy: false,
locale: navigator.language.slice(0, 2),
locale: locale,
fallbackLocale: "en",
messages,
});