Repository navigation
Conversation
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
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.
Summary
Choosing a language other than English or Chinese makes the frontend fetch
./locales/<locale>.json, which React Native never ships: onlybundled_devtools_locales(en-USandzh, set upstream inconfig/gni/i18n.gni) are packaged, and the rest are meant to come from Chrome'sremoteBaseCDN, which React Native never passes. The dev server logsError: 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
languagesettingit, DevTools opened through dev-middleware's/open-debugger),it.jsonanswers 404, Metro logs theENOENT, and the app warns before falling back to English: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-USwithout a request. With a remote base, every locale is offered as before.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.htmlin headless Chrome for Testing withnavigator.languageset. Before is the published@react-native/debugger-frontend@0.88.0; after is this commit's release GN build (is_debug=false, so noen-XL) with locales other thanen-USandzhremoved, 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.
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>withsizeset to its option count.After, with an Italian system language and the setting stored as
itorbrowserLanguage: onlyen-US.jsonis 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
zhorbrowserLanguage,zh.jsonloads (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.tspasses.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
devtools-frontendrepo following the contribution guide for Meta employees OR contribution guide.