From 24e819a5336ac3c0bf6e4fef01c822d914c809c4 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Sun, 17 Nov 2024 14:51:22 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(frontend)=20use=20browser=20langua?= =?UTF-8?q?ge=20if=20no=20localStorage=20for=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, language detection was failing to read browser settings correctly. Added explicit detection order to ensure localStorage preferences are checked before falling back to browser language. --- src/frontend/src/i18n/init.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/frontend/src/i18n/init.ts b/src/frontend/src/i18n/init.ts index 352c56dc..01b4d49b 100644 --- a/src/frontend/src/i18n/init.ts +++ b/src/frontend/src/i18n/init.ts @@ -13,11 +13,14 @@ i18n ) .use(initReactI18next) .use(LanguageDetector) -i18n.init({ - supportedLngs: ['en', 'fr'], - fallbackLng: 'en', - ns: i18nDefaultNamespace, - interpolation: { - escapeValue: false, - }, -}) + .init({ + supportedLngs: ['en', 'fr'], + fallbackLng: 'fr', + ns: i18nDefaultNamespace, + detection: { + order: ['localStorage', 'navigator'], + }, + interpolation: { + escapeValue: false, + }, + })