feat: default UI language to browser language when available#3690
Merged
Conversation
On first visit, match navigator.languages against the available locales instead of always falling back to en_US. Tries an exact match (en-US -> en_US) then a language-only match (fr -> fr_FR), falling back to en_US when none apply. A saved preference still takes precedence. Fixes #3139 Generated-By: PostHog Code Task-Id: a1ecc509-0fd8-44fd-b203-f69e4bd18c65
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the frontend bootstrap so RomM defaults its UI language to the user’s browser preferences when no saved locale is present, improving first-visit UX while keeping the existing saved-preference precedence.
Changes:
- Added browser-language detection/matching logic to the language store.
- Switched initial locale selection in
RomM.vueto use the new browser-language detection when no saved locale matches.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/stores/language.ts | Adds detectBrowserLanguage() to map navigator.languages to a shipped locale, with fallback behavior. |
| frontend/src/RomM.vue | Uses detectBrowserLanguage() during app bootstrap when no stored locale matches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
navigator.languages is universally supported, so drop the navigator.language fallback and the redundant empty-entry guard. Generated-By: PostHog Code Task-Id: a1ecc509-0fd8-44fd-b203-f69e4bd18c65
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.
Description
Explain the changes or enhancements you are proposing with this pull request.
On first visit RomM always started in English (
en_US), ignoring the browser's preferred language even when a matching locale was available. This PR makes the app default to the browser language when it maps to one of the shipped locales.Precedence on startup is now:
localStorage["settings.locale"](or a logged-in user'sui_settings.locale). Unchanged, still wins.navigator.languagesmatched against the available locales.en_US— final fallback when nothing matches.Matching tries an exact match first (
en-US->en_US, normalizing the separator and casing) then a language-only match (fr->fr_FR), walkingnavigator.languagesin preference order. A returning user's explicit choice is never overridden. This applies to both v1 and v2 since they share the sameRomM.vuebootstrap and language store.Fixes #3139
Checklist
Please check all that apply.
Screenshots (if applicable)
N/A — behavioral change only.
AI assistance disclosure: This change was implemented with AI assistance (PostHog Code / Claude). The browser-language detection logic, the wiring in
RomM.vue, and this PR description were AI-generated, then reviewed by a human. Verified locally withnpm run typecheckandtrunk check.Created with PostHog Code