Skip to content

Commit

Permalink
Improve i18n support, close amir20#2417
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Oct 12, 2023
1 parent 732df99 commit a78d7d9
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 a78d7d9

Please sign in to comment.