fix: reload entire page when changing language

- Changed selectLanguage() to reload full page instead of HTMX partial update
- Fixes issue where info modal content stayed in original language
- Ensures all UI elements (including modals) update correctly on language change
This commit is contained in:
juanatsap
2025-11-10 19:29:22 +00:00
parent 125b3e2c81
commit 4522d47a7e
+3 -22
View File
@@ -599,32 +599,13 @@
const urlHadLangParam = new URLSearchParams(window.location.search).has('lang');
function selectLanguage(lang) {
// Update button states
document.querySelectorAll('.language-selector .selector-btn').forEach(btn => {
btn.classList.remove('active');
});
event.target.closest('.selector-btn').classList.add('active');
// Save language preference to localStorage
localStorage.setItem('cv-language', lang);
// Use HTMX to load new content
htmx.ajax('GET', `/cv?lang=${lang}`, {
target: '#cv-content',
swap: 'innerHTML swap:200ms settle:200ms',
indicator: '#loading'
});
// Update URL only if it originally had lang parameter
// Reload page with new language parameter
const url = new URL(window.location);
if (urlHadLangParam) {
url.searchParams.set('lang', lang);
window.history.pushState({}, '', url);
}
// If URL is clean, keep it clean (don't add lang parameter)
// Update html lang attribute
document.documentElement.lang = lang;
url.searchParams.set('lang', lang);
window.location.href = url.toString();
}
function toggleCVLength() {