Refonte de la navigation en français et amélioration de la redirection linguistique
This commit is contained in:
@@ -2,17 +2,18 @@
|
||||
(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 supportedLangs = ['fr', 'nl']; // Liste des langues supportées
|
||||
var storedLang = localStorage.getItem('preferredLang');
|
||||
var navigatorLang = (navigator.language || navigator.userLanguage).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 + '/';
|
||||
|
||||
// Redirige vers la langue stockée si présente, sinon vers la langue du navigateur
|
||||
if (currentPath === '/') {
|
||||
if (storedLang && storedLang !== '') {
|
||||
window.location.href = '/' + storedLang;
|
||||
} else if (supportedLangs.includes(navigatorLang)) {
|
||||
window.location.href = '/' + navigatorLang;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user