Skip to content

feat: add check sync | missing to lingui cli#2515

Open
yslpn wants to merge 12 commits into
lingui:mainfrom
yslpn:feat/lingui-check-sync-missing
Open

feat: add check sync | missing to lingui cli#2515
yslpn wants to merge 12 commits into
lingui:mainfrom
yslpn:feat/lingui-check-sync-missing

Conversation

@yslpn

@yslpn yslpn commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a dedicated lingui check command for validating catalogs without writing output files.

It is based on #2506 and should be merged after that PR.

It also closes #2195 by adding a CI-friendly way to check catalogs without running compilation.

Included in this PR:

  • lingui check missing to fail when translations are still missing after fallbackLocales are applied, matching lingui compile --strict
  • lingui check missing --mode catalog to fail on catalog-level missing translations before fallbackLocales are applied
  • lingui check sync to fail when catalogs are out of sync with lingui extract
  • Shared missing-translation handling that ignores obsolete catalog entries in both resolved and catalog modes

In packages/format-po/src/po.ts, PO serialization was updated to preserve meaningful existing header state, merge custom headers deterministically, and drop empty default gettext headers. This makes serialization more stable and avoids noisy diffs, which is important for check sync.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Fixes #2195
Related to #2506

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@vercel

vercel Bot commented Apr 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
js-lingui Ready Ready Preview May 1, 2026 11:29am

Request Review

@yslpn yslpn changed the title Feat/lingui check sync missing feat: add check sync | missing to lingui cli Apr 16, 2026
@codecov

codecov Bot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.33724% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.83%. Comparing base (6bb8983) to head (18d7faa).
⚠️ Report is 329 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/lingui-check.ts 65.88% 25 Missing and 4 partials ⚠️
packages/cli/src/lingui-compile.ts 20.00% 7 Missing and 1 partial ⚠️
packages/cli/src/api/check/sync.ts 88.57% 4 Missing ⚠️
packages/format-po/src/po.ts 93.75% 3 Missing ⚠️
packages/cli/src/api/check/index.ts 93.75% 2 Missing ⚠️
packages/cli/src/api/catalog/translations.ts 90.90% 1 Missing ⚠️
packages/cli/src/api/messages.ts 87.50% 1 Missing ⚠️
packages/loader/src/webpackLoader.ts 91.66% 1 Missing ⚠️
packages/vite-plugin/src/index.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2515       +/-   ##
===========================================
+ Coverage   77.05%   88.83%   +11.78%     
===========================================
  Files          84      125       +41     
  Lines        2157     3680     +1523     
  Branches      555     1088      +533     
===========================================
+ Hits         1662     3269     +1607     
+ Misses        382      369       -13     
+ Partials      113       42       -71     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new lingui check CLI namespace to validate catalogs (missing translations and extract-sync drift) without producing compilation artifacts, while aligning missing-translation semantics with fallbackLocales and stabilizing PO serialization to make sync checks deterministic.

Changes:

  • Introduces lingui check sync (detects out-of-sync catalogs vs extract dry-run) and lingui check missing (fails on raw missing translations before fallbacks).
  • Updates strict-missing semantics across CLI compile, loader, and Vite plugin via missingBehavior: "catalog".
  • Improves PO header normalization/order to preserve meaningful state and avoid noisy diffs; updates related fixtures/snapshots/tests.

Reviewed changes

Copilot reviewed 48 out of 48 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website/docs/ref/cli.md Documents check commands and clarifies compile --strict semantics
packages/vite-plugin/test/vite-plugin.test.ts Adds coverage for fail-on-missing with fallback locales
packages/vite-plugin/test/fail-on-missing-fallback/locale/en-US.po Test fixture for fallback-missing scenario
packages/vite-plugin/test/fail-on-missing-fallback/locale/en-GB.po Test fixture with a raw missing entry
packages/vite-plugin/test/fail-on-missing-fallback/lingui.config.js Test config enabling fallbackLocales
packages/vite-plugin/test/fail-on-missing-fallback/entrypoint.js Test entrypoint importing a PO file
packages/vite-plugin/src/index.ts Uses missingBehavior: "catalog" for fail-on-missing checks
packages/loader/test/loader.test.ts Adds coverage for fail-on-missing with fallback locales
packages/loader/test/fail-on-missing-fallback/locale/en-US.po Loader test fixture for fallback-missing scenario
packages/loader/test/fail-on-missing-fallback/locale/en-GB.po Loader test fixture with a raw missing entry
packages/loader/test/fail-on-missing-fallback/lingui.config.js Loader test config enabling fallbackLocales
packages/loader/test/fail-on-missing-fallback/entrypoint.js Loader test entrypoint importing a PO file
packages/loader/src/webpackLoader.ts Uses missingBehavior: "catalog" for fail-on-missing checks
packages/format-po/src/po.ts Stabilizes PO header normalization and deterministic header ordering
packages/format-po/src/po.test.ts Adds tests for idempotent serialization and header preservation/merging
packages/cli/test/extractor-experimental/expected/index.page.pl.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental/expected/index.page.en.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental/expected/about.page.pl.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental/expected/about.page.en.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental-clean/expected/index.page.pl.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental-clean/expected/index.page.en.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental-clean/expected/about.page.pl.po Updates expected PO output (drops empty default headers)
packages/cli/test/extractor-experimental-clean/expected/about.page.en.po Updates expected PO output (drops empty default headers)
packages/cli/test/extract-partial-consistency/expected/en.po Updates expected PO output (drops empty default headers)
packages/cli/src/test/compile.test.ts Adds strict missing test when fallbacks would resolve translation
packages/cli/src/test/checkTestUtils.ts Shared helpers for check-command tests
packages/cli/src/test/check-sync.test.ts Tests check sync behavior (dry-run extract parity)
packages/cli/src/test/check-registry.test.ts Tests check registry resolution and option validation
packages/cli/src/test/check-missing.test.ts Tests check missing semantics (raw missing, pseudo locale, filters)
packages/cli/src/test/check-cli.test.ts Tests CLI program wiring for check
packages/cli/src/test/snapshots/compile.test.ts.snap Updates snapshots for new strict/missing reporting/output
packages/cli/src/lingui.ts Registers lingui check subcommand
packages/cli/src/lingui-compile.ts Updates --strict help text/examples to match new semantics
packages/cli/src/lingui-check.ts Implements lingui check CLI program runner and rendering
packages/cli/src/api/runBounded.ts Adds bounded-concurrency helper for checks
packages/cli/src/api/resolveWorkersOptions.ts Validates --workers input; preserves heuristic defaults
packages/cli/src/api/resolveWorkersOptions.test.ts Adds test for rejecting non-numeric --workers
packages/cli/src/api/formats/formatterWrapper.ts Adds serialize() to support dry-run comparisons; avoids writes when unchanged
packages/cli/src/api/formats/formatterWrapper.test.ts Tests serialization without writing and write-if-changed behavior
packages/cli/src/api/findings.ts Introduces shared finding shape for check results
packages/cli/src/api/compile/compileLocale.ts Reuses shared missing-detection logic; improves verbose missing output formatting
packages/cli/src/api/check/types.ts Defines check registry types, results, and findings
packages/cli/src/api/check/sync.ts Implements sync check (extract dry-run vs existing files)
packages/cli/src/api/check/missing.ts Implements missing check (raw missing before fallbacks)
packages/cli/src/api/check/index.ts Implements check registry + option validation
packages/cli/src/api/catalog/translations.ts Centralizes missing-detection + finding formatting for missing translations
packages/cli/src/api/catalog/getTranslationsForCatalog.ts Adds missingBehavior option and raw-missing semantics
packages/cli/src/api/catalog/getTranslationsForCatalog.test.ts Adds tests for raw-missing reporting with fallbacks enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/api/formats/formatterWrapper.ts
Comment thread packages/cli/src/api/check/sync.ts Outdated
Comment thread packages/cli/src/lingui-check.ts Outdated
@yslpn yslpn marked this pull request as draft April 29, 2026 20:46
@yslpn yslpn marked this pull request as ready for review May 1, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a command to check for missing translations

3 participants