@koehler8/cms 1.0.0-beta.24 → 1.0.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Header.vue +11 -0
- package/src/router/index.js +13 -0
package/package.json
CHANGED
|
@@ -414,6 +414,17 @@ const updateLocaleMenuPosition = () => {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
isLangOpen.value = false;
|
|
417
|
+
// Persist the user's explicit choice so it survives navigation to the
|
|
418
|
+
// unprefixed base-locale URL (`/`). The router guard only writes
|
|
419
|
+
// localStorage when a locale param is present in the URL — clicking
|
|
420
|
+
// the base locale navigates to `/` (no param), so the write must
|
|
421
|
+
// happen here instead. Also keeps loadConfigData's localStorage
|
|
422
|
+
// fallback in sync with the active selection.
|
|
423
|
+
if (!import.meta.env.SSR && typeof localStorage !== 'undefined') {
|
|
424
|
+
try {
|
|
425
|
+
localStorage.setItem('locale', locale);
|
|
426
|
+
} catch {}
|
|
427
|
+
}
|
|
417
428
|
};
|
|
418
429
|
|
|
419
430
|
onMounted(() => {
|
package/src/router/index.js
CHANGED
|
@@ -136,6 +136,19 @@ export function applyRouterGuards(router, localePrefixes = computeLocalePrefixes
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (!import.meta.env.SSR) {
|
|
139
|
+
// Browser-language auto-redirect on first visit only. If the user
|
|
140
|
+
// already has a stored locale preference (set by either an explicit
|
|
141
|
+
// dropdown click or a previous visit to a locale-prefixed URL),
|
|
142
|
+
// respect that — don't second-guess them with browser-language
|
|
143
|
+
// detection. This prevents the bug where clicking "EN" on /de
|
|
144
|
+
// navigates to / and the auto-detect bounces back to /de because
|
|
145
|
+
// the browser is set to German.
|
|
146
|
+
let storedPreference = '';
|
|
147
|
+
try {
|
|
148
|
+
storedPreference = (localStorage.getItem('locale') || '').toString().toLowerCase();
|
|
149
|
+
} catch {}
|
|
150
|
+
if (storedPreference) return;
|
|
151
|
+
|
|
139
152
|
const navLang = (navigator.language || navigator.userLanguage || '').toString();
|
|
140
153
|
const shortLang = normalizeLocale(navLang || '');
|
|
141
154
|
|