Skip to content

Commit

Permalink
fix: don't report statistics for pseudo locale (#2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexturpin authored Nov 27, 2024
1 parent e559999 commit 113c05d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cli/src/api/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions packages/cli/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<rootDir>/actual/{locale}",
include: ["<rootDir>/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)
`)
})
})
})

0 comments on commit 113c05d

Please sign in to comment.