diff --git a/front_end/core/i18n/i18n.test.ts b/front_end/core/i18n/i18n.test.ts index 63d41ea9d782..d9b126d8f4ea 100644 --- a/front_end/core/i18n/i18n.test.ts +++ b/front_end/core/i18n/i18n.test.ts @@ -205,3 +205,16 @@ describe('fetchAndRegisterLocaleData', () => { `Actually called with ${fetchStub.args[0][0]}`); }); }); + +describe('supported locales without a remote base', () => { + it('offers only the bundled locales', () => { + const locales = i18n.i18n.getAllSupportedDevToolsLocales(); + assert.includeMembers(locales, ['en-US', 'zh']); + assert.notInclude(locales, 'it'); + }); + + it('resolves an unbundled locale to en-US', () => { + assert.strictEqual(i18n.i18n.lookupClosestSupportedDevToolsLocale('it-IT'), 'en-US'); + assert.strictEqual(i18n.i18n.lookupClosestSupportedDevToolsLocale('zh-CN'), 'zh'); + }); +}); diff --git a/front_end/core/i18n/i18nImpl.ts b/front_end/core/i18n/i18nImpl.ts index bb9d4e9443fe..7ac3eddd7c5a 100644 --- a/front_end/core/i18n/i18nImpl.ts +++ b/front_end/core/i18n/i18nImpl.ts @@ -16,7 +16,10 @@ import { REMOTE_FETCH_PATTERN, } from './locales.js'; -const i18nInstance = new I18n.I18n.I18n(LOCALES, DEFAULT_LOCALE); +// [RN] React Native ships only the bundled locales and has no remoteBase to fetch +// the rest from, so offer and resolve to the bundled locales only. +const i18nInstance = new I18n.I18n.I18n( + Root.Runtime.getRemoteBase()?.version ? LOCALES : BUNDLED_LOCALES_GENERATED, DEFAULT_LOCALE); // All the locales that are part of the DevTools bundle and should not be fetched // remotely.