Rule based number formatting
Number spelling based on the pure Python implementation of the CLDR RBNF engine.
Currently only supports whole numbers (cardinal, ordinal, year) as fractional numbers are not well-defined and not universally implemented in CLDR.
Based on the original PR #660 with useful enhancements from @akx at #682 and additional work from the original author:
- extensive test cases are generated
- dataclass added to make parsing context more readable in code
- linting and debugging including the removal of recursion errors
Extensive test cases are added, but should be considered smoke tests until a native speaker reviews them for each language.
Based on an earlier discussion: https://github.com/python-babel/babel/pull/114 and referenced in https://github.com/python-babel/babel/issues/179
Supersedes #682
Codecov Report
:x: Patch coverage is 97.88732% with 6 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 92.27%. Comparing base (50635d8) to head (bb56a15).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| babel/rbnf.py | 97.83% | 6 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #1232 +/- ##
==========================================
+ Coverage 91.93% 92.27% +0.33%
==========================================
Files 27 28 +1
Lines 4688 4972 +284
==========================================
+ Hits 4310 4588 +278
- Misses 378 384 +6
| Flag | Coverage Δ | |
|---|---|---|
| macos-14-3.10 | 91.15% <94.01%> (+0.17%) |
:arrow_up: |
| macos-14-3.11 | 91.31% <97.88%> (+0.39%) |
:arrow_up: |
| macos-14-3.12 | 91.51% <97.88%> (+0.38%) |
:arrow_up: |
| macos-14-3.13 | 91.51% <97.88%> (+0.38%) |
:arrow_up: |
| macos-14-3.8 | 91.02% <94.01%> (+0.18%) |
:arrow_up: |
| macos-14-3.9 | 91.08% <94.01%> (+0.17%) |
:arrow_up: |
| macos-14-pypy3.10 | 91.15% <94.01%> (+0.17%) |
:arrow_up: |
| ubuntu-24.04-3.10 | 91.17% <94.01%> (+0.17%) |
:arrow_up: |
| ubuntu-24.04-3.11 | 91.33% <97.88%> (+0.39%) |
:arrow_up: |
| ubuntu-24.04-3.12 | 91.53% <97.88%> (+0.38%) |
:arrow_up: |
| ubuntu-24.04-3.13 | 91.53% <97.88%> (+0.38%) |
:arrow_up: |
| ubuntu-24.04-3.8 | 91.04% <94.01%> (+0.18%) |
:arrow_up: |
| ubuntu-24.04-3.9 | 91.10% <94.01%> (+0.17%) |
:arrow_up: |
| ubuntu-24.04-pypy3.10 | 91.17% <94.01%> (+0.17%) |
:arrow_up: |
| windows-2022-3.10 | 91.16% <94.01%> (+0.17%) |
:arrow_up: |
| windows-2022-3.11 | 91.32% <97.88%> (+0.39%) |
:arrow_up: |
| windows-2022-3.12 | 91.52% <97.88%> (+0.38%) |
:arrow_up: |
| windows-2022-3.13 | 91.52% <97.88%> (+0.38%) |
:arrow_up: |
| windows-2022-3.8 | 91.13% <94.01%> (+0.17%) |
:arrow_up: |
| windows-2022-3.9 | 91.09% <94.01%> (+0.17%) |
:arrow_up: |
| windows-2022-pypy3.10 | 91.16% <94.01%> (+0.17%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.