Skip to content

catalog: Keep explicitly declared plural forms without a locale - #1318

Merged
akx merged 1 commit into
masterfrom
catalog-plural-forms
Aug 17, 2026
Merged

catalog: Keep explicitly declared plural forms without a locale#1318
akx merged 1 commit into
masterfrom
catalog-plural-forms

Conversation

@akx

@akx akx commented Aug 17, 2026

Copy link
Copy Markdown
Member

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...)

@codspeed-hq

codspeed-hq Bot commented Aug 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing catalog-plural-forms (31b27bc) with master (4ca7a30)

Open in CodSpeed

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.47%. Comparing base (a8a1a74) to head (31b27bc).
⚠️ Report is 2 commits behind head on master.

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     
Flag Coverage Δ
macos-14-3.10 91.56% <100.00%> (+0.09%) ⬆️
macos-14-3.11 91.50% <100.00%> (+0.09%) ⬆️
macos-14-3.12 91.70% <100.00%> (+0.09%) ⬆️
macos-14-3.13 91.70% <100.00%> (+0.09%) ⬆️
macos-14-3.14 ?
macos-14-3.15 91.68% <100.00%> (+0.09%) ⬆️
macos-14-3.8 91.43% <100.00%> (+0.09%) ⬆️
macos-14-3.9 91.49% <100.00%> (+0.09%) ⬆️
macos-14-pypy3.10 91.56% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.10 91.58% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.11 91.52% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.12 91.72% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.13 91.72% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.14 91.70% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.15 91.70% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.8 91.45% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-3.9 91.51% <100.00%> (+0.09%) ⬆️
ubuntu-24.04-pypy3.10 91.58% <100.00%> (+0.09%) ⬆️
windows-2022-3.10 91.57% <100.00%> (+0.09%) ⬆️
windows-2022-3.11 ?
windows-2022-3.12 91.71% <100.00%> (+0.09%) ⬆️
windows-2022-3.13 91.71% <100.00%> (+0.09%) ⬆️
windows-2022-3.14 91.69% <100.00%> (+0.09%) ⬆️
windows-2022-3.15 91.69% <100.00%> (+0.09%) ⬆️
windows-2022-3.8 91.54% <100.00%> (+0.09%) ⬆️
windows-2022-3.9 ?
windows-2022-pypy3.10 91.57% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@akx
akx marked this pull request as ready for review August 17, 2026 06:08
@akx
akx requested a lite review from Copilot August 17, 2026 06:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-Forms headers even when Catalog.locale is None.
  • Make num_plurals / plural_expr no 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.

Comment thread babel/messages/catalog.py Outdated
Comment thread tests/messages/test_pofile_write.py Outdated
Comment thread babel/messages/catalog.py
@akx
akx force-pushed the catalog-plural-forms branch from 1577b77 to df2e96d Compare August 17, 2026 06:26
@akx
akx requested a lite review from Copilot August 17, 2026 06:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread tests/messages/test_pofile_write.py
If a catalog declares plural forms but no language header,
Babel would previously lose the plural information.
@akx
akx force-pushed the catalog-plural-forms branch from df2e96d to 31b27bc Compare August 17, 2026 06:43
@akx
akx requested a lite review from Copilot August 17, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@akx
akx enabled auto-merge (squash) August 17, 2026 06:46
@akx
akx merged commit f8fb262 into master Aug 17, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants