Skip to content

Commit 933011a

Browse files
authored
Scope locale selection to bundled languages only (#287)
1 parent 58f2922 commit 933011a

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎front_end/core/i18n/i18n.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,16 @@ describe('fetchAndRegisterLocaleData', () => {
205205
`Actually called with ${fetchStub.args[0][0]}`);
206206
});
207207
});
208+
209+
describe('supported locales without a remote base', () => {
210+
it('offers only the bundled locales', () => {
211+
const locales = i18n.i18n.getAllSupportedDevToolsLocales();
212+
assert.includeMembers(locales, ['en-US', 'zh']);
213+
assert.notInclude(locales, 'it');
214+
});
215+
216+
it('resolves an unbundled locale to en-US', () => {
217+
assert.strictEqual(i18n.i18n.lookupClosestSupportedDevToolsLocale('it-IT'), 'en-US');
218+
assert.strictEqual(i18n.i18n.lookupClosestSupportedDevToolsLocale('zh-CN'), 'zh');
219+
});
220+
});

‎front_end/core/i18n/i18nImpl.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import {
1616
REMOTE_FETCH_PATTERN,
1717
} from './locales.js';
1818

19-
const i18nInstance = new I18n.I18n.I18n(LOCALES, DEFAULT_LOCALE);
19+
// [RN] React Native ships only the bundled locales and has no remoteBase to fetch
20+
// the rest from, so offer and resolve to the bundled locales only.
21+
const i18nInstance = new I18n.I18n.I18n(
22+
Root.Runtime.getRemoteBase()?.version ? LOCALES : BUNDLED_LOCALES_GENERATED, DEFAULT_LOCALE);
2023

2124
// All the locales that are part of the DevTools bundle and should not be fetched
2225
// remotely.

0 commit comments

Comments
 (0)