fix: redirect to lang parameter when loading from localStorage
- Change from HTMX partial update to full page redirect - Ensures modal and all UI elements render in correct language - Uses window.location.replace() to avoid history pollution
This commit is contained in:
+4
-16
@@ -732,22 +732,10 @@
|
||||
const savedLang = localStorage.getItem('cv-language');
|
||||
|
||||
if (!urlLang && savedLang) {
|
||||
// URL is clean but we have a saved preference - load that language
|
||||
htmx.ajax('GET', `/cv?lang=${savedLang}`, {
|
||||
target: '#cv-content',
|
||||
swap: 'innerHTML swap:0ms settle:0ms'
|
||||
});
|
||||
|
||||
// Update button states
|
||||
document.querySelectorAll('.language-selector .selector-btn').forEach(btn => {
|
||||
btn.classList.remove('active');
|
||||
if (btn.getAttribute('onclick').includes(savedLang)) {
|
||||
btn.classList.add('active');
|
||||
}
|
||||
});
|
||||
|
||||
// Update html lang attribute
|
||||
document.documentElement.lang = savedLang;
|
||||
// URL is clean but we have a saved preference - redirect with lang parameter
|
||||
const url = new URL(window.location);
|
||||
url.searchParams.set('lang', savedLang);
|
||||
window.location.replace(url.toString());
|
||||
} else if (urlLang) {
|
||||
// Save URL language to localStorage
|
||||
localStorage.setItem('cv-language', urlLang);
|
||||
|
||||
Reference in New Issue
Block a user