Skip to content

Commit

Permalink
Set correct HTML lang attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Oct 11, 2023
1 parent de6645a commit 9174c79
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ void i18n
});

export default i18n;

const updateAttributes = (lng: string) => {
document.documentElement.setAttribute("lang", lng);
// TODO: add this at some point. Needs lots of fixing.
// const dir = languages.find(l => l.short === lng)?.rtl ? "rtl" : "ltr";
// document.documentElement.setAttribute("dir", dir);
};

i18n.on("languageChanged", updateAttributes);
if (i18n.resolvedLanguage) {
updateAttributes(i18n.resolvedLanguage);
}

0 comments on commit 9174c79

Please sign in to comment.