PO Gettext extract does not generate correct plural placeholders
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 457
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 16
Description
### 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
- [x] I've checked [the docs](https://lingui.dev) and this isn't covered there.
- [x] I've searched existing issues on [GitHub](https://github.com/lingui/js-lingui/issues).
### Reproduction Steps
Add any plural
```tsx
{plural(count, {
one: "one book",
other: "many books",
})}
```
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:
```po
#. 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
```po
#. 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_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with `lingui extract`, the provided plural examples, and the `ru` locale. Trace how plural metadata becomes PO `msgstr` entries; done means the generated PO contains four empty plural translations matching the locale's plural rules instead of two.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, react, typescript
- Domain
- cli, internationalization, localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100