Skip to content

Commit

Permalink
Improve i18n support, close #2417 (#2418)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello authored Oct 15, 2023
1 parent 59c72f9 commit 55775f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assets/modules/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 55775f6

Please sign in to comment.