Skip to content

fix: resolve locale for logged-out visitors from browser/localStorage#5634

Open
bakill3 wants to merge 1 commit intousememos:mainfrom
bakill3:fix/locale-logged-out
Open

fix: resolve locale for logged-out visitors from browser/localStorage#5634
bakill3 wants to merge 1 commit intousememos:mainfrom
bakill3:fix/locale-logged-out

Conversation

@bakill3
Copy link

@bakill3 bakill3 commented Feb 15, 2026

Problem:

Logged-out visitors always see English because useUserLocale returned early when userGeneralSetting was undefined, and i18n.init()had no lng set (the detection config referenced a plugin that was never loaded).

Fix:

  • i18n.ts: resolve initial locale at module load (query param → localStorage → navigator.languages → "en") so the first render is correct.
  • useUserLocale.ts: remove early return → run getLocaleWithFallback() for all users.
  • utils/i18n.ts: add normalizeLocale() helper, query param support, and navigator.languages iteration.

Locale priority (both logged-in and logged-out):

  1. ?locale=xx query parameter
  2. User setting (authenticated only)
  3. localStorage("memos-locale")
  4. navigator.languages
  5. "en"

@bakill3 bakill3 requested a review from johnnyjoygh as a code owner February 15, 2026 18:54
@boojack boojack self-requested a review as a code owner February 24, 2026 14:23
@boojack boojack force-pushed the main branch 2 times, most recently from 2b6b987 to 47d9414 Compare February 24, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant