catalog: Keep explicitly declared plural forms without a locale - #1318
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1318 +/- ##
==========================================
+ Coverage 92.38% 92.47% +0.09%
==========================================
Files 27 27
Lines 4937 4919 -18
==========================================
- Hits 4561 4549 -12
+ Misses 376 370 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a Babel Catalog edge case where explicitly declared Plural-Forms headers could be lost when no locale/language is set, and removes surprising side effects where reading plural-related properties mutated internal state.
Changes:
- Preserve explicitly declared
Plural-Formsheaders even whenCatalog.localeisNone. - Make
num_plurals/plural_exprno longer populate internal plural fields on read. - Add regression tests covering explicit plural headers without locale, and ensuring templates don’t accidentally emit
Plural-Forms.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/messages/test_pofile_write.py |
Adds tests ensuring explicit plural headers survive without a locale and templates don’t emit plural headers just from property access. |
babel/messages/catalog.py |
Adjusts header generation to retain explicit plural forms and changes plural property access to avoid mutating internal state. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1577b77 to
df2e96d
Compare
If a catalog declares plural forms but no language header, Babel would previously lose the plural information.
df2e96d to
31b27bc
Compare
If a catalog declares plural forms but no language header, Babel would previously lose the plural information.
(Also, accessing properties would set internals, which was weird...)