Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Locale matching now recognizes Brazilian Portuguese and other supported locales when system tags contain extensions or underscores. Explicit language choices and existing fallback behavior remain unchanged. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…resolver Underscore system tags such as pt_BR-u-nu-latn never reached the extension-stripped exact match, so normalize separators first. Move the regression cases next to the shared resolver, where they also check the original tag is kept for formatting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dismissing prior approval to re-evaluate d0f873c
Problem
When a browser, phone, or OS reports Brazilian Portuguese with a Unicode locale extension (for example
pt-BR-u-nu-latn), the System language setting loads English or the next preferred language instead of the installedpt-BRcatalog. The shared matcher inpackages/client-runtime/src/locales.tscompared the whole tag, then only the bare language (pt), and neither equalspt-BR. Web passesnavigator.languagesstraight in (apps/web/src/i18n/runtime.ts→resolveWebLocaleSelection), as do mobile (I18nProvider) and Electron main (desktop/src/i18n/messages.ts).Deterministic repro on
origin/main(95a3ec546411b62869d36a8f45ae2eaf91ddb769), from the checkout root:{ catalogLocale: "en", formattingLocale: "en-GB" }(bare["pt-BR", "en-GB"]givespt-BR).{ catalogLocale: "pt-BR", formattingLocale: "pt-BR-u-nu-latn" }.In the web app: set
navigator.languagesto["pt-BR-u-nu-latn", "en-GB"]and choose System default; on main the UI stays English, with the fixdocument.langispt-BRand Settings reads "Configurações".Change
The shared matcher also compares the tag without its BCP 47 extensions (everything from the first single-character subtag) before falling back to the bare language. The original tag is still used for formatting.
pt-PTstill does not map topt-BR, and Traditional Chinese handling is unchanged. Because web, mobile, and Electron main all use this matcher, the one change fixes all three.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
apps/web/src/i18n/locales.test.tsgets three cases:pt-BR-u-nu-latn, mixed-casePT-br-u-nu-latn, and apt-PTnegative control. On base, the two extension cases fail (catalogLocale"en"instead of"pt-BR"). On head, all 8 pass.vp run check:changedexits 0 (format, lint, knip, typecheck, tests).Not shown: browser screenshots of the localized UI, a mobile device run, and a packaged Electron run. All three use the shared resolver tested above.
Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).
Not shown