Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't report statistics for pseudo locale #2094

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
`)
})
})
})
Loading