Repository navigation
Load only the visitor's locale on web - #575
Merged
Merged
Conversation
Every locale JSON was bundled into the web __common chunk, so each visitor downloaded all five languages to read one. English stays bundled as the fallback; the others are split into their own chunks and fetched by an i18next backend the first time they are needed. BrandProvider now keeps the loading screen up until the locale LocaleProvider is about to apply has loaded, so a non-English visitor never sees English first. Locale resolution moves to utils/resolveLocale.ts unchanged so both contexts can use it.
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
Every locale JSON was bundled into the web
__commonchunk, so each visitor downloaded all five languages to read one. English stays bundled as the fallback. The others are split into their own chunks (i18n/loaders.ts) and fetched by an i18next backend the first time they are needed, sochangeLanguageandloadLanguagesresolve once the translations are in.BrandProviderkeeps the loading screen up until the localeLocaleProvideris about to apply has loaded. A non-English visitor never sees English first; the extra wait sits behind the spinner that is already there. Locale resolution moves unchanged fromLocaleContexttoutils/resolveLocale.tsso both contexts can call it.Follow-up to #574.
Related issue
None.
Scope
Changes
__commongoes from 1.2 MB to 783 KB raw.fr,es,deandnlare ~100 KB raw chunks each.jest.setup.tsmocks@/i18n/loaderswithrequire. Four tests read a French bundle throughgetFixedT("fr")and nowawait i18n.loadLanguages("fr")first. No app code reads a locale that way.Local Lighthouse 13.6.0, mobile preset,
expo exportserved withserve -s dist, English visitor, median of 3, againstmainafter #574:/locationsbefore/locationsafterTesting
OpenRestoApi.Testspass locally (no API changes)npm run check,tsc --noEmit,check:doc-links,npm testandnpm run test:android(311 suites each),expo export --platform webOPENRESTO_DEFAULT_LOCALE=de: only German ever rendered, including on a throttled 200 KB/s link; only thedechunk downloaded.frpick: only French rendered; only thefrchunk downloaded.frchunk and flips the page, no errors.import()is inlined by Metro off web, so the native bundle still carries every locale.Migrations
Checklist