67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
/**
|
|
* Language Manager
|
|
* Simplified to use only German language
|
|
*/
|
|
|
|
const languageManager = {
|
|
currentLang: 'de', // Default language set to German
|
|
|
|
init: function() {
|
|
console.log('Initializing Language Manager');
|
|
|
|
// Always use German as the language
|
|
this.currentLang = 'de';
|
|
localStorage.setItem('preferredLanguage', 'de');
|
|
|
|
// Apply translations
|
|
this.applyTranslations();
|
|
|
|
// Update document language attribute
|
|
document.documentElement.lang = this.currentLang;
|
|
|
|
console.log(`Language Manager initialized with language: ${this.currentLang}`);
|
|
},
|
|
|
|
applyTranslations: function() {
|
|
if (typeof translations === 'undefined' || !translations['de']) {
|
|
console.error('German translations not available');
|
|
return;
|
|
}
|
|
|
|
const elements = document.querySelectorAll('[data-i18n]');
|
|
elements.forEach(element => {
|
|
const key = element.getAttribute('data-i18n');
|
|
const translation = translations['de'][key];
|
|
if (translation) {
|
|
if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') {
|
|
if (element.hasAttribute('placeholder')) {
|
|
element.setAttribute('placeholder', translation);
|
|
} else {
|
|
element.value = translation;
|
|
}
|
|
} else {
|
|
element.textContent = translation;
|
|
}
|
|
} else {
|
|
console.warn(`Missing translation for key: ${key}`);
|
|
}
|
|
});
|
|
|
|
const altElements = document.querySelectorAll('[data-i18n-alt]');
|
|
altElements.forEach(element => {
|
|
const key = element.getAttribute('data-i18n-alt');
|
|
const translation = translations['de'][key];
|
|
if (translation) {
|
|
element.setAttribute('alt', translation);
|
|
}
|
|
});
|
|
|
|
console.log(`Applied German translations`);
|
|
}
|
|
};
|
|
|
|
// Initialize the language manager when the DOM is ready
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
languageManager.init();
|
|
});
|