fix(i18n): ensure contact modal displays in correct language when opened

Fixed issue where clicking "Kontakt" in German mode showed English contact form.

Changes:
- Re-apply translations when modal opens (ensures current language is used)
- Use translated "submitting" text for sending state (DE: "Senden...", FR: "Envoi en cours...")
- Use translated submit button text when re-enabled
- Remove duplicate success message text

Now clicking "Kontakt" in DE mode or "Nous contacter" in FR mode correctly shows the modal in that language.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-10-26 18:37:40 +13:00
parent ca0ea92790
commit e2de187fa4

View file

@ -175,7 +175,7 @@
<!-- Success Message --> <!-- Success Message -->
<div id="contact-success" class="hidden bg-green-50 border border-green-200 text-green-800 px-4 py-3 rounded"> <div id="contact-success" class="hidden bg-green-50 border border-green-200 text-green-800 px-4 py-3 rounded">
<span data-i18n="contact_modal.success_message">Thank you for contacting us! We will respond within 24 hours.</span>! We'll respond within 24 hours. <span data-i18n="contact_modal.success_message">Thank you for contacting us! We will respond within 24 hours.</span>
</div> </div>
<!-- Error Message --> <!-- Error Message -->
@ -268,6 +268,10 @@
const openModal = () => { const openModal = () => {
modal.classList.remove('hidden'); modal.classList.remove('hidden');
// Re-apply translations to modal when opening
if (window.I18n && window.I18n.applyTranslations) {
window.I18n.applyTranslations();
}
document.getElementById('contact-name')?.focus(); document.getElementById('contact-name')?.focus();
}; };
@ -313,7 +317,9 @@
// Disable submit button // Disable submit button
submitBtn.disabled = true; submitBtn.disabled = true;
submitBtn.textContent = 'Sending...'; // Use translation if available, fallback to English
const sendingText = window.I18n?.translations?.contact_modal?.submitting || 'Sending...';
submitBtn.textContent = sendingText;
try { try {
// Get CSRF token from cookie // Get CSRF token from cookie
@ -354,7 +360,9 @@
} finally { } finally {
// Re-enable submit button // Re-enable submit button
submitBtn.disabled = false; submitBtn.disabled = false;
submitBtn.textContent = 'Send Message'; // Use translation if available, fallback to English
const submitText = window.I18n?.translations?.contact_modal?.submit_button || 'Send Message';
submitBtn.textContent = submitText;
} }
}); });
} }