The page is constantly reloading since you are not checking whether the user is on the correct language site.
On your pages, you can save a javascript variable for the server-side page language. For instance:
var thisLanguage = 'en';
Then change your JavaScript logic to take this into account, and only apply redirection if the user language is different from thisLanguage :
$(document).ready(function () { var userLang = navigator.language || navigator.userLanguage; if (userLang != thisLanguage){ switch (userLang) { case 'en': window.location.href = window.location.origin + '/en'; break; case 'de': window.location.href = window.location.origin + '/de'; break; default: break; } } });
source share