Skip to content

fix(i18n): include locale assets in package builds - #9587

Open
bulunote wants to merge 2 commits into
makeplane:previewfrom
bulunote:agent/i18n-locale-runtime
Open

fix(i18n): include locale assets in package builds#9587
bulunote wants to merge 2 commits into
makeplane:previewfrom
bulunote:agent/i18n-locale-runtime

Conversation

@bulunote

@bulunote bulunote commented Aug 12, 2026

Copy link
Copy Markdown

Description

The built @plane/i18n package currently emits its JavaScript and declaration files without the JSON locale resources consumed by the runtime loader. In addition, the emitted loader resolves ../locales/..., which points outside the package's dist directory. Consumers that run against the packaged build can therefore fail to load non-English resources even though the source locale files exist.

This PR fixes the packaging boundary for every supported locale by:

  • copying src/locales to dist/locales as part of the tsdown build;
  • resolving dynamic resource imports from ./locales/... in the emitted entry;
  • adding build-level regression tests that compare every source and built JSON asset and verify the emitted import path; and
  • using the named createInstance import while touching the loader, which keeps the changed file lint-clean without changing behavior.

This is deliberately limited to the i18n package runtime and build output. It does not change translations, application UI copy, database content, or deployment configuration.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Not applicable. This fixes package build output rather than a visual component.

Test Scenarios

  • pnpm --filter @plane/i18n test
    • builds the package;
    • verifies all 532 locale JSON assets are present in dist/locales; and
    • verifies the emitted loader imports ./locales/${language}/${namespace}.json.
  • pnpm --filter @plane/i18n check:types
  • pnpm --filter @plane/i18n check:sync
    • all 19 locales contain the same 3,837 keys.
  • Changed-file OxLint with --deny-warnings
  • Changed-file oxfmt check
  • pnpm turbo run build --filter=web --output-logs=errors-only
    • 11/11 tasks completed successfully.
  • git diff --check

References

Summary by CodeRabbit

  • Bug Fixes

    • Fixed locale loading in built packages so translated content is available at runtime.
    • Ensured locale assets are included and resolved correctly in production builds.
  • Tests

    • Added automated checks confirming built locale files match source assets and dynamic loading works as expected.
    • Added a test command for building the package and running TypeScript tests.

@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f777a179-52e3-44aa-919a-335221500e69

📥 Commits

Reviewing files that changed from the base of the PR and between dd0379f and 02dd9d8.

📒 Files selected for processing (1)
  • packages/i18n/scripts/tsconfig.json

📝 Walkthrough

Walkthrough

The i18n package build copies locale assets and loads them from the bundled path. Tests compare source and built locale files and verify dynamic locale imports in the built entry.

Changes

i18n locale asset handling

Layer / File(s) Summary
Bundle locale assets
packages/i18n/tsdown.config.ts, packages/i18n/src/core/instance.ts
The build copies src/locales. The i18n instance uses createInstance and resolves locale JSON files from ./locales.
Validate locale bundle
packages/i18n/package.json, packages/i18n/scripts/__tests__/locale-assets.test.ts, packages/i18n/scripts/tsconfig.json
The test script builds the package before running TypeScript tests. The tests compare source and built locale assets and verify dynamic locale imports. The test compiler includes ES2023 library definitions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • makeplane/plane#9590: Both PRs modify the shared @plane/i18n runtime and its locale-loading setup.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely states that locale assets are included in i18n package builds.
Description check ✅ Passed The description covers the required sections, explains the fix, identifies the change type, and lists detailed test scenarios.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@bulunote
bulunote marked this pull request as ready for review August 12, 2026 00:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/i18n/scripts/__tests__/locale-assets.test.ts`:
- Around line 12-19: Update the scripts TypeScript configuration to include the
ES2023 library definition so listJsonAssets can use toSorted without type
errors; preserve the existing Node runtime configuration and implementation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 83b0543f-7999-49d7-aaa4-1cb373ac137d

📥 Commits

Reviewing files that changed from the base of the PR and between 1c8a60f and dd0379f.

📒 Files selected for processing (4)
  • packages/i18n/package.json
  • packages/i18n/scripts/__tests__/locale-assets.test.ts
  • packages/i18n/src/core/instance.ts
  • packages/i18n/tsdown.config.ts

Comment thread packages/i18n/scripts/__tests__/locale-assets.test.ts
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.

2 participants