feat(12-01): update i18n store lang init to use navigator.language fallback
- Replace hardcoded 'fr' default with IIFE that checks localStorage first - Falls back to navigator.language: 'en' if starts with 'en', else 'fr' - localStorage preference always wins over browser language setting
This commit is contained in:
@@ -25,7 +25,11 @@
|
|||||||
|
|
||||||
// i18n store: FR/EN toggle, persists in localStorage
|
// i18n store: FR/EN toggle, persists in localStorage
|
||||||
Alpine.store('i18n', {
|
Alpine.store('i18n', {
|
||||||
lang: localStorage.getItem('imptune_lang') || 'fr',
|
lang: (() => {
|
||||||
|
const saved = localStorage.getItem('imptune_lang');
|
||||||
|
if (saved) return saved;
|
||||||
|
return navigator.language && navigator.language.startsWith('en') ? 'en' : 'fr';
|
||||||
|
})(),
|
||||||
t(key) {
|
t(key) {
|
||||||
return (this.translations[this.lang] || {})[key] || key;
|
return (this.translations[this.lang] || {})[key] || key;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user