Skip to content

Commit

Permalink
fix(format-po-gettext): bad return during mapping with `serializePlur…
Browse files Browse the repository at this point in the history
…als` (#1707)
  • Loading branch information
stovmascript authored Jun 22, 2023
1 parent ff96df4 commit 993bd2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
},
}
`;
4 changes: 4 additions & 0 deletions packages/format-po-gettext/src/fixtures/messages_plural.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/format-po-gettext/src/po-gettext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}}",
Expand Down
2 changes: 1 addition & 1 deletion packages/format-po-gettext/src/po-gettext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function serializePlurals(
const icuMessage = message.message

if (!icuMessage) {
return
return item
}

const _simplifiedMessage = icuMessage.replace(LINE_ENDINGS, " ")
Expand Down

1 comment on commit 993bd2a

@vercel
Copy link

@vercel vercel bot commented on 993bd2a Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.