Skip to content

Open in the browser's language until someone picks one - #91

Closed
stupleb wants to merge 1 commit into
TraceApps:devfrom
stupleb:fix/browser-language
Closed

stupleb wants to merge 1 commit into
TraceApps:devfrom
stupleb:fix/browser-language

Conversation

@stupleb

@stupleb stupleb commented Nov 10, 2026

Copy link
Copy Markdown

pickInitialLocale() starts the app in the browser's language, and main.js says the saved setting takes over once it loads. But the language setting defaults to 'en', and $: if ($language) locale.set($language) in App.svelte treats that default as a choice, so the browser's language is replaced with English straight away. A Spanish or Swedish browser gets English everywhere, the sign-in page included, until the person finds Settings > Regional & Units and picks their language.

This makes the setting start empty, so nothing replaces the browser's language until someone picks one. Settings > Regional & Units shows $language || $locale, so the picker shows the language in use rather than a blank select while nothing is saved. A language someone picks is saved and wins over the browser's, as before. Nothing else reads the setting: the server, the Android app and the watch don't use it.

What I ran

  • npm run i18n:check and npm test on node:24-bookworm: 1162 tests, all passing.
  • A production build served by this branch's server, in headless Chrome driven over the DevTools protocol:
    • With the browser set to Spanish (navigator.language is es-ES), the sign-in page is in Spanish. On dev it's in English.
    • Signed in with nothing saved, Settings is in Spanish, and Regional & Units shows Español.
    • Picking English saves language: "en", and after a reload the app is in English while the browser stays Spanish.
    • An English browser sees no change, and a Swedish one gets Swedish.

There's no new test: the change is a store default and one binding, so I checked it in a browser instead. NutriTrace's dev has the same default and the same line in App.svelte.

Both this and #90 add a line under Fixed in CHANGELOG.md, so whichever merges second needs a one-line rebase.

The language setting defaulted to 'en', and App.svelte applies any truthy value over the locale picked from the browser, so a Spanish or Swedish browser still got English, sign-in page included. The setting now starts empty, so the browser's language stands until one is picked, and Settings > Regional & Units shows the language in use while it's empty.
@thebigjoe1

Copy link
Copy Markdown
Contributor

Thanks! This is on dev now (fd11848), done the same way as in NutriTrace.

@thebigjoe1 thebigjoe1 closed this Nov 13, 2026
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.

2 participants