document.addEventListener('DOMContentLoaded', function() { const userLanguage = navigator.language || navigator.userLanguage; if (userLanguage.toLowerCase().startsWith('es')) { function triggerLanguageButton() { const selector = document.querySelector('.select-other-language'); if (selector && selector.getAttribute('aria-expanded') === 'false') { selector.setAttribute('aria-expanded', 'true'); const clickEvent = new Event('click', { bubbles: true, cancelable: true }); selector.dispatchEvent(clickEvent); // Optional: Manual class toggle if framework doesn't respond const langPrompt = document.querySelector('.lang-prompt-BG'); if (langPrompt) { langPrompt.classList.remove('language-prompt-close'); langPrompt.classList.add('language-prompt-open'); } // Debug console.log('Language button triggered'); } else if (!selector) { setTimeout(triggerLanguageButton, 500); // Retry if button not found } } // Small delay to ensure framework initialization setTimeout(triggerLanguageButton, 100); } });