Per language translation splitting and lazy loading #13
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: hloth/lufin#13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently the bundle includes all paraglide's languages which totals to ~800 kb
If we can make languages lazy load, user would have to load the main app + ~25 kb of translations instead of almost a megabyte.
Blocked by https://github.com/opral/inlang-paraglide-js/issues/88
Your build likely has an issue that is unrelated to paraglide js.
If your SPA is not split by page/route, the entire app is loaded at once. Irrespective of async
await import()
calls. Your bundler shouldawait import()
by page, which enables per page translations. The latter is hyper efficient, see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/benchmark.The only Paragelide JS related problem that comes to mind is that you use dynamic keys which bypass tree-shaking https://inlang.com/m/gerre34r/library-inlang-paraglideJs/basics#dynamically-calling-messages
That's because the app itself is mostly one page with majority of translated strings in it. I believe splitting build by pages won't shrink bundle size compared to splitting locales and only load the one selected.
Is your app one single page or do you have multiple? Looking at the demo, you have one page. If that's the case, then indeed per page/component splitting wont help.
We would need per locale builds here. But that's the crux. How do we ahieve per locale builds with vite?
I thought about dynamically loading translation files by using
await import
but from your tests it appears that this will take 10 times longer than just loading 800kb of all translations bundled with the app. We can't know which locale user wants before downloading main bundle, executing javascript and determining their preferred language.