From 993bd2ad5c864fc2fde89986feb7fe55ef55af92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0=C5=A5ov=C3=AD=C4=8Dek?= <14262802+stovmascript@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:37:19 +0200 Subject: [PATCH] fix(format-po-gettext): bad return during mapping with `serializePlurals` (#1707) --- .../src/__snapshots__/po-gettext.test.ts.snap | 17 +++++++++++++++++ .../src/fixtures/messages_plural.po | 4 ++++ .../format-po-gettext/src/po-gettext.test.ts | 3 +++ packages/format-po-gettext/src/po-gettext.ts | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/format-po-gettext/src/__snapshots__/po-gettext.test.ts.snap b/packages/format-po-gettext/src/__snapshots__/po-gettext.test.ts.snap index 2b4a74944..4f84d62e7 100644 --- a/packages/format-po-gettext/src/__snapshots__/po-gettext.test.ts.snap +++ b/packages/format-po-gettext/src/__snapshots__/po-gettext.test.ts.snap @@ -72,6 +72,10 @@ msgstr "" "Language-Team: \\n" "Plural-Forms: \\n" +#. js-lingui-explicit-id +msgid "static" +msgstr "Static message" + #. js-lingui-explicit-id #. js-lingui:pluralize_on=count msgid "message_with_id_and_octothorpe" @@ -161,5 +165,18 @@ exports[`po-gettext format should convert gettext plurals to ICU plural messages origin: [], translation: , }, + static: { + comments: [ + js-lingui-explicit-id, + ], + context: null, + extra: { + flags: [], + translatorComments: [], + }, + obsolete: false, + origin: [], + translation: Static message, + }, } `; diff --git a/packages/format-po-gettext/src/fixtures/messages_plural.po b/packages/format-po-gettext/src/fixtures/messages_plural.po index 37ca5ab65..ada6ea7ca 100644 --- a/packages/format-po-gettext/src/fixtures/messages_plural.po +++ b/packages/format-po-gettext/src/fixtures/messages_plural.po @@ -7,6 +7,10 @@ msgstr "" "X-Generator: @lingui/cli\n" "Language: en\n" +#. js-lingui-explicit-id +msgid "static" +msgstr "Static message" + #. js-lingui:pluralize_on=someCount #. js-lingui-explicit-id msgid "message_with_id" diff --git a/packages/format-po-gettext/src/po-gettext.test.ts b/packages/format-po-gettext/src/po-gettext.test.ts index 32b54f29a..40233886e 100644 --- a/packages/format-po-gettext/src/po-gettext.test.ts +++ b/packages/format-po-gettext/src/po-gettext.test.ts @@ -32,6 +32,9 @@ describe("po-gettext format", () => { it("should convert ICU plural messages to gettext plurals", () => { const catalog: CatalogType = { + static: { + translation: "Static message", + }, message_with_id_and_octothorpe: { message: "{count, plural, one {Singular} other {Number is #}}", translation: "{count, plural, one {Singular} other {Number is #}}", diff --git a/packages/format-po-gettext/src/po-gettext.ts b/packages/format-po-gettext/src/po-gettext.ts index 726d1c292..6d45b30a6 100644 --- a/packages/format-po-gettext/src/po-gettext.ts +++ b/packages/format-po-gettext/src/po-gettext.ts @@ -54,7 +54,7 @@ function serializePlurals( const icuMessage = message.message if (!icuMessage) { - return + return item } const _simplifiedMessage = icuMessage.replace(LINE_ENDINGS, " ")