feat(i18n): auto-detect browser language with localStorage persistence (closes #29)#40
Open
zqleslie wants to merge 3 commits into
Open
feat(i18n): auto-detect browser language with localStorage persistence (closes #29)#40zqleslie wants to merge 3 commits into
zqleslie wants to merge 3 commits into
Conversation
closes davz7#29) - On init, read localStorage.getItem('ms-lang') first - If absent, parse navigator.language — if starts with 'en', use 'en'; otherwise default to 'es' - fallbackLng stays as 'es'
closes davz7#29) - Add i18next-browser-languagedetector to dependencies - Configure detection: localStorage ('ms-lang') → navigator.language → fallback 'es' - Navigator language: starts with 'en' → 'en', else → 'es' - Persist user choice on language toggle in AppHeader - Remove hardcoded lng: 'es' - fallbackLng remains 'es'
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Auto-detects the user's browser language on init and persists manual language toggles in
localStorage, so the app remembers the user's preference across sessions.Changes
1.
CreditRoot/src/i18n/index.jsi18next-browser-languagedetectorvia.use(LanguageDetector)lng: 'es'order: ['localStorage', 'navigator']— readslocalStorage.getItem('ms-lang')first, falls back tonavigator.languagelookupLocalStorage: 'ms-lang'convertDetectedLanguage— if browser language starts withen, useen; otherwise default toesfallbackLngstayses2.
CreditRoot/package.json"i18next-browser-languagedetector": "^8.2.1"to dependencies3.
CreditRoot/src/components/layout/AppHeader.jsxtoggleLang()to persist user choice:localStorage.setItem('ms-lang', next)Acceptance Criteria (Issue #29)
localStorage.getItem('ms-lang')firstnavigator.language— if starts withen, useen; else defaulteslocalStorage.setItem('ms-lang', lang)fallbackLngstaysesi18next-browser-languagedetectorto dependenciesCloses #29.