Skip to content

Offer only the locales React Native ships - #287

Draft
huntie wants to merge 1 commit into
mainfrom
pr287
Draft

huntie wants to merge 1 commit into
mainfrom
pr287

Conversation

@huntie

@huntie huntie commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

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.

In the RN DevTools desktop app with a real app attached (RN 0.88.0 on an iOS Simulator, the language setting it, DevTools opened through dev-middleware's /open-debugger), it.json answers 404, Metro logs the ENOENT, and the app warns before falling back to English:

DevTools Metro
before-devtools before-metro

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.

  • NOTE: this also applies to this repo's hosted dev mode (npm start), which has no remote base either.

Fixes react/react-native#52461

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
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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant