From 113c05d91dba210b73444f4824c47d2709f8f5cf Mon Sep 17 00:00:00 2001 From: Alex Turpin Date: Wed, 27 Nov 2024 02:37:50 -0500 Subject: [PATCH] fix: don't report statistics for pseudo locale (#2094) --- packages/cli/src/api/stats.ts | 2 ++ packages/cli/test/index.test.ts | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/packages/cli/src/api/stats.ts b/packages/cli/src/api/stats.ts index d1eb9c442..3660cef37 100644 --- a/packages/cli/src/api/stats.ts +++ b/packages/cli/src/api/stats.ts @@ -30,6 +30,8 @@ export function printStats( }) Object.keys(catalogs).forEach((locale) => { + if (locale === config.pseudoLocale) return // skip pseudo locale + const catalog = catalogs[locale] // catalog is null if no catalog exists on disk and the locale // was not extracted due to a `--locale` filter diff --git a/packages/cli/test/index.test.ts b/packages/cli/test/index.test.ts index b3a6c284d..8879eef81 100644 --- a/packages/cli/test/index.test.ts +++ b/packages/cli/test/index.test.ts @@ -308,4 +308,42 @@ describe("E2E Extractor Test", () => { compareFolders(actualPath, expectedPath) }) + + it("Should not report statistics on pseudolocalizations", async () => { + const { rootDir } = await prepare("extract-po-format") + + await mockConsole(async (console) => { + const result = await extractCommand( + makeConfig({ + rootDir: rootDir, + locales: ["en", "pl", "pseudo-LOCALE"], + pseudoLocale: "pseudo-LOCALE", + sourceLocale: "en", + format: "po", + catalogs: [ + { + path: "/actual/{locale}", + include: ["/fixtures"], + }, + ], + }), + {} + ) + + expect(result).toBeTruthy() + expect(getConsoleMockCalls(console.error)).toBeFalsy() + expect(getConsoleMockCalls(console.log)).toMatchInlineSnapshot(` + Catalog statistics for actual/{locale}: + ┌─────────────┬─────────────┬─────────┐ + │ Language │ Total count │ Missing │ + ├─────────────┼─────────────┼─────────┤ + │ en (source) │ 8 │ - │ + │ pl │ 8 │ 8 │ + └─────────────┴─────────────┴─────────┘ + + (Use "yarn extract" to update catalogs with new messages.) + (Use "yarn compile" to compile catalogs for production. Alternatively, use bundler plugins: https://lingui.dev/ref/cli#compiling-catalogs-in-ci) + `) + }) + }) })