Skip to content

feat: default UI language to browser language when available#3690

Merged
gantoine merged 2 commits into
masterfrom
posthog-code/detect-browser-language
Jul 6, 2026
Merged

feat: default UI language to browser language when available#3690
gantoine merged 2 commits into
masterfrom
posthog-code/detect-browser-language

Conversation

@gantoine

@gantoine gantoine commented Jul 6, 2026

Copy link
Copy Markdown
Member

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:

  1. Saved preferencelocalStorage["settings.locale"] (or a logged-in user's ui_settings.locale). Unchanged, still wins.
  2. Browser language (new) — navigator.languages matched against the available locales.
  3. 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), walking navigator.languages in preference order. A returning user's explicit choice is never overridden. This applies to both v1 and v2 since they share the same RomM.vue bootstrap and language store.

Fixes #3139

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

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 with npm run typecheck and trunk check.


Created with PostHog Code

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
Copilot AI review requested due to automatic review settings July 6, 2026 01:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.vue to 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.

Comment thread frontend/src/stores/language.ts
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
@gantoine gantoine merged commit 6c742d1 into master Jul 6, 2026
11 checks passed
@gantoine gantoine deleted the posthog-code/detect-browser-language branch July 6, 2026 02:04
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.

[UI/UX] Default language for the interface

2 participants