Ajoute la redirection vers la page d'accueil spécifique à la langue en fonction de la langue du navigateur

This commit is contained in:
Boris Waaub
2026-01-19 12:22:52 +01:00
parent 02e333c3dc
commit 82c6f41d7f

View File

@@ -1,6 +1,20 @@
// main script
(function () {
"use strict";
(function() {
// Redirect to language-specific homepage based on browser language, default to English
var supportedLangs = ['fr', 'nl'];
var userLang = navigator.language || navigator.userLanguage;
userLang = userLang.split('-')[0];
var currentPath = window.location.pathname;
var alreadyLang = supportedLangs.some(function(lang) {
return currentPath.startsWith('/' + lang + '/');
});
if (supportedLangs.includes(userLang) && !alreadyLang) {
window.location.href = '/' + userLang + '/';
}
})();
// Dropdown Menu Toggler For Mobile
// ----------------------------------------