fix(web,space): bundle i18n locale JSON via import.meta.glob - #9860
yuzhiyang1 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughChangesInternationalization bundling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The i18n instance loaded translations through a fully dynamic template
import (`../locales/${language}/${namespace}.json`) that no bundler can
statically resolve, so locale files never reach the client bundle and the
UI renders raw translation keys for every language. Switch to
import.meta.glob expanded by vite at build time, and alias @plane/i18n
to its source in the web/space vite configs so the app build processes
the glob instead of the prebuilt dist.
4cdd477 to
1c284cf
Compare
Fixes #9858
What
Building
web/spacefrom source ships no translations: everyt()call fails at runtime and the UI renders raw i18n keys (home.title,sidebar.new_work_item, …) for all languages including English.Why
packages/i18n/src/core/instance.tsloads locales through a fully dynamic template import:Two path variables make it impossible for tsdown/vite to statically resolve. The compiled bundle keeps the native dynamic import verbatim:
so the browser 404s on
../locales/<lang>/<ns>.jsonat runtime. On a v1.4.2 source build, no locale JSON exists anywhere in the served assets.How
import.meta.glob("../locales/*/*.json"), which vite expands at build time into explicit per-file loaders (kept as a plainimport.meta.glob(...)call so vite's transform matches it);@plane/i18nto its source in theweb/spacevite configs so the glob is processed by the app build instead of the prebuiltdist.Locale JSON for all 20 languages now ships in the client bundle; language switching (e.g. to 简体中文) works end to end.
Verification
Self-hosted v1.4.2 built from source: before,
docker exec web find /usr/share/caddy/html -name '*.json' -path '*locale*'returns nothing and the UI shows keys; after, locale strings are present in the assets and the interface renders translated text.Summary by CodeRabbit