23 lines
No EOL
789 B
JavaScript
23 lines
No EOL
789 B
JavaScript
document.addEventListener('DOMContentLoaded', function() {
|
|
// Only run on the home page to avoid redirect loops
|
|
if (window.location.pathname === '/') {
|
|
const userLang = navigator.language || navigator.userLanguage;
|
|
const currentLang = document.documentElement.lang;
|
|
|
|
// Simple language mapping
|
|
const supportedLanguages = {
|
|
'de': '/de/',
|
|
'de-DE': '/de/',
|
|
'de-AT': '/de/',
|
|
'de-CH': '/de/',
|
|
'en': '/en/',
|
|
'en-US': '/en/',
|
|
'en-GB': '/en/'
|
|
};
|
|
|
|
// Check if user's language is different from current and is supported
|
|
if (supportedLanguages[userLang] && currentLang !== userLang.substring(0,2)) {
|
|
window.location.href = supportedLanguages[userLang];
|
|
}
|
|
}
|
|
}); |