Skip to content

Use the plural pattern for exact millions in compact formats - #1454

Open
jayhemnani9910 wants to merge 1 commit into
python-babel:masterfrom
jayhemnani9910:fix/compact-exact-one-plural
Open

jayhemnani9910 wants to merge 1 commit into
python-babel:masterfrom
jayhemnani9910:fix/compact-exact-one-plural

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

format_compact_decimal(1000000, format_type="long", locale="fr") returned 1 millions. Same for 1 milliards and 1 billions, in every fr locale.

French has an exact-one pattern only for 1000 ("mille"). For other magnitudes, the check picked the "1" form, found no entry, and fell back to "other" instead of the plural the number has. The "1" form is now used only when it has an entry for that magnitude.

Ran every locale for 1K, 1M, 1B and 1T, long and short, before and after: only the fr long forms change. The new assertion fails before the change. Full test suite passes.

French only has an exact-one pattern for 1000, so 1000000 skipped its
plural lookup and fell back to the "other" pattern ("1 millions").
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.67%. Comparing base (cb0c7a7) to head (a35b124).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1454   +/-   ##
=======================================
  Coverage   93.67%   93.67%           
=======================================
  Files          27       27           
  Lines        4983     4983           
=======================================
  Hits         4668     4668           
  Misses        315      315           
Flag Coverage Δ
macos-15-3.10 92.75% <100.00%> (ø)
macos-15-3.11 92.69% <100.00%> (?)
macos-15-3.12 92.95% <100.00%> (ø)
macos-15-3.13 92.95% <100.00%> (ø)
macos-15-3.14 92.93% <100.00%> (?)
macos-15-3.15 92.93% <100.00%> (ø)
macos-15-3.9 92.69% <100.00%> (ø)
macos-15-pypy3.10 92.75% <100.00%> (ø)
ubuntu-24.04-3.10 92.77% <100.00%> (ø)
ubuntu-24.04-3.11 92.71% <100.00%> (ø)
ubuntu-24.04-3.12 92.97% <100.00%> (ø)
ubuntu-24.04-3.13 92.97% <100.00%> (ø)
ubuntu-24.04-3.14 92.95% <100.00%> (ø)
ubuntu-24.04-3.15 92.95% <100.00%> (ø)
ubuntu-24.04-3.9 92.71% <100.00%> (ø)
ubuntu-24.04-pypy3.10 92.77% <100.00%> (ø)
windows-2022-3.10 92.76% <100.00%> (ø)
windows-2022-3.11 92.70% <100.00%> (ø)
windows-2022-3.12 92.96% <100.00%> (ø)
windows-2022-3.13 92.96% <100.00%> (ø)
windows-2022-3.14 92.94% <100.00%> (ø)
windows-2022-3.15 92.94% <100.00%> (ø)
windows-2022-3.9 92.70% <100.00%> (ø)
windows-2022-pypy3.10 92.76% <100.00%> (ø)

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.

@codspeed

codspeed Bot commented Nov 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing jayhemnani9910:fix/compact-exact-one-plural (a35b124) with master (cb0c7a7)

Open in CodSpeed

@akx akx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you check this against other implementations? Feels odd we'd need this special case.

@manav4u

manav4u commented Nov 10, 2026

Copy link
Copy Markdown

I checked this against Node 22.23.4 / ICU 78.3. With notation: 'compact', compactDisplay: 'long' and maximumFractionDigits: 0, French gives:

1,000       -> mille
1,000,000   -> 1 million
1,100,000   -> 1 million
1,000,000,000 -> 1 milliard
1,000,000,000,000 -> 1 billion

The CLDR 49 French data also supports keeping the normal plural when the exact-one pattern is absent at that magnitude: count="1" exists only for 1000 (mille), while 1000000 has count="one" (0 million) and count="other" (0 millions). So this guard avoids selecting an exact-one pattern from a different magnitude, rather than adding a French-specific rule.

There is an interaction with #1430 worth covering. On its current head f6411c5, the rounded-value comparison makes French 1,100,000 become 1 millions; it is 1 million on the base. Keeping that PR's rounded == 1 comparison together with this PR's per-magnitude guard gives 1 million and preserves the intended rounded mille behavior.

I ran 16 direct regression cases: fr, fr_CA, fr_BE, fr_CH at 1M, 1.1M, 1B and 1T. All 16 fail on #1430's head and pass on #1454's head and on the private combination. Twelve cover the preexisting exact-magnitude bug; the four 1.1M cases cover the behavior newly introduced by #1430.

A separate 100-case comparison across ten locales matched Node for all 100 with the combination. This is a bounded sample, not a claim about every locale or value. Babel used CLDR 49; Node reports CLDR 48.0. The original two number-test modules pass on #1454 (142 tests). On #1430 with the newer CLDR data, the same three currency-test failures occur before and after adding the guard, so I am not claiming a clean full suite.

Sharing the results for the existing PRs, not opening a competing patch. Investigation and tests were AI-assisted.

CLDR data: https://raw.githubusercontent.com/unicode-org/cldr/release-49/common/main/fr.xml

This branch has not been deployed

No deployments
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.

3 participants