Skip to content

PO Gettext extract does not generate correct plural placeholders #2345

@garikkh

Description

@garikkh

Description

When running lingui extract with locales that have different plural rules, we would expect the PO to have the correct number of msgstr for the number of plurals, but instead it just uses two (source locale, not even source code. Even if your source code has zero, one, many it will only put msgstr[0], msgstr[1]

Verifications

  • I've checked the docs and this isn't covered there.
  • I've searched existing issues on GitHub.

Reproduction Steps

Add any plural

        <div>
          <Plural
            value={count}
            one={"There's one book"}
            other={"There are # books"}
          />
        </div>

        <div>
          {plural(count, {
            one: "one book",
            other: "many books",
          })}
        </div>

And use ru in locales - good example, as it has 4 plural forms, and rule is:

"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"

Expected Behavior

Expect to see:

#. js-lingui:icu=%7Bcount%2C+plural%2C+one+%7BThere%27s+one+book%7D+other+%7BThere+are+%23+books%7D%7D&pluralize_on=count
#: src/App.tsx:52
msgid "There's one book"
msgid_plural "There are # books"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
msgstr[3] ""

Instead only get

#. js-lingui:icu=%7Bcount%2C+plural%2C+one+%7BThere%27s+one+book%7D+other+%7BThere+are+%23+books%7D%7D&pluralize_on=count
#: src/App.tsx:52
msgid "There's one book"
msgid_plural "There are # books"
msgstr[0] ""
msgstr[1] ""

Macro Support

Babel with babel-macro-plugin

Lingui Version

5.5.1

Babel Version

No response

Framework

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions