Skip to content

Use pattern grouping sizes in format_decimal - #16

Merged
synesthesiam merged 1 commit into
mainfrom
fix-indian-grouping
Nov 17, 2026
Merged

synesthesiam merged 1 commit into
mainfrom
fix-indian-grouping

Conversation

@synesthesiam

Copy link
Copy Markdown
Member

Follow-up to #15.

What

format_decimal always grouped digits in threes ("{:,}"), ignoring the grouping in the pattern. Now that =#,##,##0= replace rules go through it (#15), Indian-style patterns came out wrong:

Input Before After
hi digits-ordinal-masculine 1234567 1,234,567वाँ 12,34,567वाँ
ta digits-ordinal 1234567 1,234,567. 12,34,567.
hi spellout-cardinal 10**18 1,000,000,000,000,000,000 10,00,00,00,00,00,00,00,000

Affects Hindi, Tamil, Nepali and Chakma (ccp).

How

Read the primary grouping size (digits after the last comma) and the secondary size (digits between the last two commas, or the primary size if there is only one comma) from the pattern, as ICU DecimalFormat does. #,##0 → (3, 3), #,##,##0 → (3, 2). Negative values keep their sign.

Tests

  • New format_decimal tests for Indian grouping, negatives, no grouping, and 1e18
  • Engine test for Hindi digits-ordinal-masculine 1234567 → 12,34,567वाँ
  • Full suite passes (131 tests); black, isort, flake8, mypy and pylint clean

Also adds an Unreleased changelog entry covering #15 and this change.

🤖 Generated with Claude Code

format_decimal always grouped digits in threes, so Indian patterns like
=#,##,##0= (Hindi, Tamil, Nepali, Chakma) printed 1,234,567 instead of
12,34,567. Derive the primary and secondary grouping sizes from the
pattern, as ICU DecimalFormat does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@synesthesiam
synesthesiam merged commit 5911fcd into main Nov 17, 2026
1 check passed
@synesthesiam
synesthesiam deleted the fix-indian-grouping branch November 17, 2026 19:53
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.

1 participant