Skip to content

Commit 8cae5e0

Browse files
authored
fix: Allow empty translations for pseudo locale in compile --strict (#2129)
1 parent 099820a commit 8cae5e0

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

packages/cli/src/lingui-compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function command(
4545
},
4646
})
4747

48-
if (!options.allowEmpty && missingMessages.length > 0) {
48+
if (!options.allowEmpty && locale !== config.pseudoLocale && missingMessages.length > 0) {
4949
console.error(
5050
chalk.red(
5151
`Error: Failed to compile catalog for locale ${chalk.bold(locale)}!`

packages/cli/src/test/compile.test.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ describe("CLI Command: Compile", () => {
88
// todo
99
})
1010

11-
function getConfig(rootDir: string) {
11+
function getConfig(rootDir: string, pseudoLocale?: string) {
1212
return makeConfig({
1313
locales: ["en", "pl"],
1414
sourceLocale: "en",
15+
pseudoLocale: pseudoLocale,
1516
rootDir: rootDir,
1617
catalogs: [
1718
{
@@ -100,6 +101,42 @@ msgstr ""
100101
}
101102
)
102103

104+
it(
105+
"Should allow empty translation for pseudo locale",
106+
async () => {
107+
expect.assertions(4)
108+
109+
const rootDir = await createFixtures({
110+
"/test": {
111+
"en.po": `
112+
msgid "Hello World"
113+
msgstr "Hello World"
114+
`,
115+
"pl.po": `
116+
msgid "Hello World"
117+
msgstr ""
118+
`,
119+
},
120+
})
121+
122+
const config = getConfig(rootDir, 'pl')
123+
124+
await mockConsole(async (console) => {
125+
const result = await command(config, {
126+
allowEmpty: false,
127+
})
128+
const actualFiles = readFsToJson(config.rootDir)
129+
130+
expect(actualFiles["pl.js"]).toBeTruthy()
131+
expect(actualFiles["en.js"]).toBeTruthy()
132+
133+
const log = getConsoleMockCalls(console.error)
134+
expect(log).toBeUndefined()
135+
expect(result).toBeTruthy()
136+
})
137+
}
138+
)
139+
103140
it("Should show missing messages verbosely when verbose = true", async () => {
104141
expect.assertions(2)
105142
const rootDir = await createFixtures({

0 commit comments

Comments
 (0)