Skip to content

Report extra PO plural forms without changing parse - #1324

Open
adarshx01 wants to merge 2 commits into
python-babel:masterfrom
adarshx01:fix/keep-extra-plural-forms
Open

Report extra PO plural forms without changing parse#1324
adarshx01 wants to merge 2 commits into
python-babel:masterfrom
adarshx01:fix/keep-extra-plural-forms

Conversation

@adarshx01

@adarshx01 adarshx01 commented Aug 17, 2026

Copy link
Copy Markdown

Fixes #1323.

read_po still drops msgstr[N] entries where N >= nplurals and pads message.string to catalog.num_plurals, same as it has for a decade. Extra forms are counted on message.discarded_plural_forms so num_plurals() can fail on a parsed catalog instead of always seeing a matching length.

read_po dropped msgstr[N] entries past nplurals, so the num_plurals
checker always saw a matching count on parsed catalogs.
@akx

akx commented Aug 17, 2026

Copy link
Copy Markdown
Member

This would change how Babel has parsed files for a decade. #1323 didn't yet include analysis as to what to do about the issue, just that it exists.

@adarshx01

Copy link
Copy Markdown
Author

Fair point — dropping extra msgstr[N] on read has been the parse behaviour for a long time, and #1323 only showed that the checker is a no-op after that, not what to do about it.

I went this way because num_plurals already runs on Catalog objects, so extra forms have to survive read_po for the check to mean anything. Happy to close this if you'd rather keep the historical parse and treat extras only at check time, or leave the checker as-is.

Keep the historical read_po truncation of msgstr[N] past nplurals, but
count those dropped entries so num_plurals() can still report them.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adarshx01

Copy link
Copy Markdown
Author

Pushed a follow-up that keeps the historical parse.

read_po still drops msgstr[N] when N >= nplurals and still pads message.string to catalog.num_plurals, so catalogs and write_po look the same as they have for a decade. The extra entries are counted on message.discarded_plural_forms so num_plurals() can report them instead of always seeing a matching length after the drop.

@adarshx01 adarshx01 changed the title Keep extra plural forms when reading PO files Report extra PO plural forms without changing parse Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

num_plurals checker is toothless on parsed pofiles

2 participants