Features: - Complete Luftglanz drone cleaning website - AI chat assistant integrated with OpenAI API - Expert product advice for AGO Quart and Mellerud cleaning products - Formal German language support (Sie form) - Secure PHP backend for API calls - Responsive design with mobile support - Product-specific knowledge base - Safety statements from manufacturers - Multi-page integration (index, products, services, contact) Technical components: - AI chat widget (js/ai-chat.js) - Chat styling (css/components/ai-chat.css) - Backend API (ai-chat-api.php) - Product knowledge base with detailed specifications - Demo and documentation files
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();
|
|
});
|