Skip to content

fix: Report correct number of missing messages in strict mode#992

Merged
semoal merged 1 commit into
lingui:mainfrom
orangain:fix-number-of-missing-traslations
Mar 1, 2021
Merged

fix: Report correct number of missing messages in strict mode#992
semoal merged 1 commit into
lingui:mainfrom
orangain:fix-number-of-missing-traslations

Conversation

@orangain
Copy link
Copy Markdown
Contributor

Problem

There are two problems about the report of missing translations of lingui compile --strict:

  1. The command reports the total number of translations not as the number of missing ones.
  2. With --verbose option, missing values, which are always undefined, are reported. It is less useful.

Changes

This PR fixes the above problems. Under the following situation:

$ npx lingui extract
Catalog statistics for src/locales/{locale}/messages:
┌─────────────┬─────────────┬─────────┐
│ Language    │ Total count │ Missing │
├─────────────┼─────────────┼─────────┤
│ en (source) │      4      │    -    │
│ cs          │      4      │    3    │
└─────────────┴─────────────┴─────────┘

(use "npm run extract" to update catalogs with new messages)
(use "npm run compile" to compile catalogs for production)

Before

Reports the total number of translations as the number of missing ones:

$ npx lingui compile --strict
Compiling message catalogs…
Error: Failed to compile catalog for locale cs!
Missing 4 translation(s)

Reports undefined as the missing translations:

$ npx lingui compile --strict --verbose
Compiling message catalogs…
en ⇒ src/locales/en/messages.js
Error: Failed to compile catalog for locale cs!
Missing translations:
undefined
Příchozí zprávy
undefined
undefined

After

Reports the correct number of missing translations:

$ npx lingui compile --strict
Compiling message catalogs…
Error: Failed to compile catalog for locale cs!
Missing 3 translation(s)

Reports missing translation message Ids:

$ npx lingui compile --strict --verbose
Compiling message catalogs…
en ⇒ src/locales/en/messages.js
Error: Failed to compile catalog for locale cs!
Missing translations:
Last login on {0}.
See all <0>unread messages</0> or <1>mark them</1> as read.
{messagesCount, plural, one {There's # message in your inbox.} other {There are # messages in your inbox.}}

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 27, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/lingui-js/js-lingui/FvVh3jF63jCy8qWYsi16fb9Z7ERH
✅ Preview: https://js-lingui-git-fork-orangain-fix-number-of-missing-t-370c16.vercel.app

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2021

Codecov Report

Merging #992 (d01c1a6) into main (77ec0bd) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #992   +/-   ##
=======================================
  Coverage   83.30%   83.30%           
=======================================
  Files          53       53           
  Lines        1605     1605           
  Branches      430      430           
=======================================
  Hits         1337     1337           
  Misses        156      156           
  Partials      112      112           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77ec0bd...d01c1a6. Read the comment docs.

@semoal semoal merged commit 128f3e2 into lingui:main Mar 1, 2021
@semoal
Copy link
Copy Markdown
Contributor

semoal commented Mar 1, 2021

Lgtm, thanks mate

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