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:
+3
-22
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user