From 286911cf890bdabb8cfb87cedfce4a102191334e Mon Sep 17 00:00:00 2001 From: Thibaut Valentin Date: Mon, 16 Mar 2026 12:19:30 +0100 Subject: [PATCH] fix: language detection --- src/main/webapp/src/config/i18n.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/src/config/i18n.js b/src/main/webapp/src/config/i18n.js index c11ff67..32d0d76 100644 --- a/src/main/webapp/src/config/i18n.js +++ b/src/main/webapp/src/config/i18n.js @@ -6,8 +6,18 @@ import {initReactI18next} from 'react-i18next'; const vite_url = import.meta.env.VITE_URL; const options = { - order: [ 'querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'], + order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'], caches: [], + convertDetectedLanguage: (lng) => { + const supportedLngs = ['en', 'fr']; + const languagePart = lng.split('-')[0]; + + if (supportedLngs.includes(languagePart)) { + return languagePart; // Manually return 'en' from 'en-US' + } + + return lng; + }, } i18n @@ -22,8 +32,12 @@ i18n // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ + fallbackLng: { + 'fr-FR': ['fr'], + default: ['en'] + }, supportedLngs: ['fr', 'en'], - fallbackLng: 'fr', + nonExplicitSupportedLngs: true, debug: vite_url.startsWith('http://localhost'), interpolation: { escapeValue: false, // not needed for react as it escapes by default -- 2.49.0