Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions front_end/core/i18n/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
5 changes: 4 additions & 1 deletion front_end/core/i18n/i18nImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading