Skip to content

Commit b1c7aac

Browse files
fix(cli): catalogsMergePath generates only one compiled locale (#2238)
1 parent f2cccd1 commit b1c7aac

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

packages/cli/src/lingui-compile.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,17 @@ export async function command(
8484
}
8585

8686
if (doMerge) {
87-
return await compileAndWrite(
87+
const result = await compileAndWrite(
8888
locale,
8989
config,
9090
options,
9191
await getCatalogForMerge(config),
9292
mergedCatalogs
9393
)
94+
95+
if (!result) {
96+
return false
97+
}
9498
}
9599
}
96100
return true

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ These errors fail command execution because \`--strict\` option passed
4343
`;
4444
4545
exports[`CLI Command: Compile merge Should merge individual catalogs if catalogsMergePath specified in lingui config 1`] = `/*eslint-disable*/module.exports={messages:JSON.parse("{\\"Z3YTTJ\\":[\\"Foo Hello World\\"],\\"iWZSiH\\":[\\"Bar Hello World\\"]}")};`;
46+
47+
exports[`CLI Command: Compile merge Should merge individual catalogs if catalogsMergePath specified in lingui config 2`] = `/*eslint-disable*/module.exports={messages:JSON.parse("{\\"Z3YTTJ\\":[\\"[PL] Foo Hello World\\"],\\"iWZSiH\\":[\\"[PL] Bar Hello World\\"]}")};`;

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ msgstr "Hello {hello"
187187
describe("merge", () => {
188188
function getConfig(rootDir: string, pseudoLocale?: string) {
189189
return makeConfig({
190-
locales: ["en"],
190+
locales: ["en", "pl"],
191191
sourceLocale: "en",
192192
pseudoLocale: pseudoLocale,
193193
rootDir,
@@ -206,7 +206,7 @@ msgstr "Hello {hello"
206206
}
207207

208208
it("Should merge individual catalogs if catalogsMergePath specified in lingui config", async () => {
209-
expect.assertions(3)
209+
expect.assertions(4)
210210

211211
const rootDir = await createFixtures({
212212
"/components/foo.tsx": "",
@@ -219,6 +219,14 @@ msgstr "Foo Hello World"
219219
msgid "Bar Hello World"
220220
msgstr "Bar Hello World"
221221
`,
222+
"/pl/foo.tsx.po": `
223+
msgid "Foo Hello World"
224+
msgstr "[PL] Foo Hello World"
225+
`,
226+
"/pl/bar.tsx.po": `
227+
msgid "Bar Hello World"
228+
msgstr "[PL] Bar Hello World"
229+
`,
222230
})
223231

224232
const config = getConfig(rootDir)
@@ -228,6 +236,7 @@ msgstr "Bar Hello World"
228236

229237
const actualFiles = readFsToListing(config.rootDir)
230238
expect(actualFiles["merged/en.js"]).toMatchSnapshot()
239+
expect(actualFiles["merged/pl.js"]).toMatchSnapshot()
231240

232241
const log = getConsoleMockCalls(console.error)
233242
expect(log).toBeUndefined()

0 commit comments

Comments
 (0)