From a35b12462d5f58462e95194fa9ab0ab6a0f70687 Mon Sep 17 00:00:00 2001 From: Jay Hemnani <193022578+jayhemnani9910@users.noreply.github.com> Date: Tue, 10 Nov 2026 00:39:27 +0530 Subject: [PATCH] Use the plural pattern for exact millions in compact formats French only has an exact-one pattern for 1000, so 1000000 skipped its plural lookup and fell back to the "other" pattern ("1 millions"). --- babel/numbers.py | 2 +- tests/test_numbers_format_decimal.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/babel/numbers.py b/babel/numbers.py index 83424ec19..2f9894c24 100644 --- a/babel/numbers.py +++ b/babel/numbers.py @@ -696,7 +696,7 @@ def _get_compact_format( plural_form = locale.plural_form(abs(scaled)) if plural_form not in compact_format: plural_form = "other" - if scaled == 1 and "1" in compact_format: + if scaled == 1 and str(magnitude) in compact_format.get("1", {}): plural_form = "1" if str(magnitude) not in compact_format[plural_form]: plural_form = "other" # fall back to other as the implicit default diff --git a/tests/test_numbers_format_decimal.py b/tests/test_numbers_format_decimal.py index 124c5b96d..c9074286b 100644 --- a/tests/test_numbers_format_decimal.py +++ b/tests/test_numbers_format_decimal.py @@ -169,6 +169,7 @@ def test_compact(): assert numbers.format_compact_decimal(1234, locale='it', format_type='long') == '1 mila' assert numbers.format_compact_decimal(1000, locale='fr', format_type='long') == 'mille' assert numbers.format_compact_decimal(1234, locale='fr', format_type='long') == '1 millier' + assert numbers.format_compact_decimal(1000000, locale='fr', format_type='long') == '1 million' assert numbers.format_compact_decimal( 12345, format_type="short", locale='ar_EG', fraction_digits=2, numbering_system='default', ) == '12٫34\xa0ألف'