From 380880137e50ff966aebacb0a6c9dbe4d32db839 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Mon, 5 May 2025 17:12:00 +0200 Subject: [PATCH] Keep the HTML lang attribute in sync with the i18next language (#3247) --- src/initializer.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/initializer.tsx b/src/initializer.tsx index 1087dc94..d0797e9d 100644 --- a/src/initializer.tsx +++ b/src/initializer.tsx @@ -136,6 +136,11 @@ export class Initializer { lookup: () => getUrlParams().lang ?? undefined, }); + // Synchronise the HTML lang attribute with the i18next language + i18n.on("languageChanged", (lng) => { + document.documentElement.lang = lng; + }); + await i18n .use(Backend) .use(languageDetector)