Skip to content

Scope locale selection to bundled languages only - #287

Merged
huntie merged 1 commit into
mainfrom
pr287
Oct 28, 2026
Merged

huntie merged 1 commit into
mainfrom
pr287

Conversation

@huntie

@huntie huntie commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Mitigates react/react-native#52461. A full fix would be to set up and serve all locale sources via the RN dev server, which I'm not attempting today. English stays a harder default for now.

The bug

DevTools currently presents a language dropdown when the viewer locale is detected. Choosing a language other than English or Chinese makes the frontend fetch ./locales/<locale>.json, which React Native never ships: only bundled_devtools_locales (en-US and zh, set upstream in config/gni/i18n.gni) are packaged, and the rest are meant to come from Chrome's remoteBase CDN, which React Native never passes.

This leads to the dev server logging Error: ENOENT: no such file or directory, stat '…/core/i18n/locales/it.json' on every launch.

DevTools Metro
language-before-infobar before-metro

This fix (scoping down available locales to only those bundled) resolves the issue.

Test plan

Served the frontend from a static server that answers 404 for missing files, like Metro, and loaded rn_fusebox.html in headless Chrome for Testing with navigator.language set. Before is the published @react-native/debugger-frontend@0.88.0; after is this commit's release GN build (is_debug=false, so no en-XL) with locales other than en-US and zh removed, as in the published package.

  • Italian system language, default setting. Before: "DevTools is now available in Italian" with "Always match Chrome's language" and "Switch DevTools to Italian". After: no infobar.

    Before After
    language-before-infobar language-after-no-infobar
  • Settings > Preferences > Language. Before: 83 options. After: "Browser UI language", "English (US)" and "Chinese". Headless Chrome draws no native popup, so each image is the dropdown's own <select> with size set to its option count.

    Before After
    language-before-options language-after-options
  • After, with an Italian system language and the setting stored as it or browserLanguage: only en-US.json is requested, with no 404 and no fallback warning.

  • After, with a Chinese system language: the Chinese infobar still shows by default, and with the setting zh or browserLanguage, zh.json loads (200) and the UI renders in Chinese.

  • npm test -- front_end/core/i18n: 56 of 56 pass, including two new tests that only bundled locales are offered and resolved without a remote base.

  • npm run lint -- front_end/core/i18n/i18nImpl.ts front_end/core/i18n/i18n.test.ts passes.

  • Not covered: this commit in the RN DevTools desktop app with a real app attached.

  • This change maintains backwards compatibility with previous Local Storage data (if modifying settings, experiments, or other persisted client state).

Upstreaming plan

@meta-cla meta-cla Bot added the cla signed label Oct 26, 2026
@huntie huntie changed the title Fix fetching unshipped locales when there is no remote base Fall back to English without fetching locales React Native doesn't ship Oct 26, 2026
@huntie huntie changed the title Fall back to English without fetching locales React Native doesn't ship Offer only the locales React Native ships Oct 26, 2026
@huntie huntie changed the title Offer only the locales React Native ships Scope locale selection to bundled languages only Oct 28, 2026
@huntie
huntie requested a review from vzaidman October 28, 2026 19:03
@huntie
huntie marked this pull request as ready for review October 28, 2026 19:04
Choosing a language other than English or Chinese makes the frontend fetch `./locales/<locale>.json`, which React Native never ships: only `bundled_devtools_locales` (`en-US` and `zh`, set upstream in `config/gni/i18n.gni`) are packaged, and the rest are meant to come from Chrome's `remoteBase` CDN, which React Native never passes. The dev server logs `Error: ENOENT: no such file or directory, stat '…/core/i18n/locales/it.json'` on every launch, and the frontend falls back to English only once the failed request comes back.

Users get there without looking for it: with the default setting, a system language that DevTools supports shows the "DevTools is now available in …" infobar on first launch, and both of its buttons pick a locale React Native can't load. The Settings language dropdown lists every one of about 80 locales too.

When there is no remote base, build the supported-locale list from the bundled locales only. The language dropdown then offers English and Chinese, the infobar appears only for Chinese, and a stored unbundled locale (or "Browser UI language" on, say, an Italian system) resolves to `en-US` without a request. With a remote base, every locale is offered as before.

Fixes react/react-native#52461
@huntie
huntie merged commit 933011a into main Oct 28, 2026
5 checks passed
@huntie
huntie deleted the pr287 branch October 28, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants