Skip to content

fix(web,space): bundle i18n locale JSON via import.meta.glob - #9860

Open
yuzhiyang1 wants to merge 1 commit into
makeplane:previewfrom
yuzhiyang1:fix/i18n-locale-bundling
Open

yuzhiyang1 wants to merge 1 commit into
makeplane:previewfrom
yuzhiyang1:fix/i18n-locale-bundling

Conversation

@yuzhiyang1

@yuzhiyang1 yuzhiyang1 commented Sep 19, 2026

Copy link
Copy Markdown

Fixes #9858

What

Building web/space from source ships no translations: every t() 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.ts loads locales through a fully dynamic template import:

resourcesToBackend((language, namespace) => import(`../locales/${language}/${namespace}.json`))

Two path variables make it impossible for tsdown/vite to statically resolve. The compiled bundle keeps the native dynamic import verbatim:

(Object.assign({}), `../locales/${e}/${t}.json`, 4)

so the browser 404s on ../locales/<lang>/<ns>.json at runtime. On a v1.4.2 source build, no locale JSON exists anywhere in the served assets.

How

  • switch the loader to import.meta.glob("../locales/*/*.json"), which vite expands at build time into explicit per-file loaders (kept as a plain import.meta.glob(...) call so vite's transform matches it);
  • alias @plane/i18n to its source in the web/space vite configs so the glob is processed by the app build instead of the prebuilt dist.

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

  • Bug Fixes
    • Fixed translation loading in the web and space applications so localized content no longer returns errors at runtime.
    • Improved locale resource loading by ensuring available language files are bundled and loaded correctly.
    • Added clearer handling when a requested locale file is unavailable.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 2ce3bbd5-c599-44ec-ae59-f54508dfefac

📥 Commits

Reviewing files that changed from the base of the PR and between 01064a7 and 1c284cf.

📒 Files selected for processing (3)
  • apps/space/vite.config.ts
  • apps/web/vite.config.ts
  • packages/i18n/src/core/instance.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Internationalization bundling

Layer / File(s) Summary
Static locale loading
packages/i18n/src/core/instance.ts
Locale JSON files are collected with import.meta.glob. The backend invokes the matching loader and rejects missing locale files with an explicit error.
Application source aliases
apps/web/vite.config.ts, apps/space/vite.config.ts
Both Vite configurations resolve @plane/i18n to the package source entry point so Vite processes the locale glob during application builds.

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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: bundling i18n locale JSON with Vite for the web and space applications.
Description check ✅ Passed The description explains the issue, cause, implementation, and verification results. It includes a linked issue and test evidence. It does not use the template headings or select the Bug fix checkbox,…
Linked Issues check ✅ Passed Issue #9858 requires statically discoverable locale files and source-build use of the i18n source. packages/i18n/src/core/instance.ts now uses import.meta.glob("../locales/*/*.json") and resolves …
Out of Scope Changes check ✅ Passed All changed files support issue #9858. The i18n loader change fixes static locale discovery. The two Vite aliases ensure that both affected source builds process the loader from source. No unrelated p…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Warning

⚠️ This pull request shows signs of AI-generated slop (description_diff_mismatch). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CLAassistant

CLAassistant commented Sep 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.
@yuzhiyang1
yuzhiyang1 force-pushed the fix/i18n-locale-bundling branch from 4cdd477 to 1c284cf Compare September 19, 2026 08:11
@yuzhiyang1
yuzhiyang1 changed the base branch from master to preview September 19, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Building web/space from source ships no translations — UI renders raw i18n keys

2 participants