Skip to content

Conversation

@DenverCoder1
Copy link
Contributor

@DenverCoder1 DenverCoder1 commented Nov 17, 2022

Fixes #931

  • Adds support for patterns with no numbers
  • In compact format, only uses "one" format if the number pluralizes to "one" before rounding
  • In compact format, explicit "1" formats can now be applied (there seem to be none with explicit "0" formats)
>>> numbers.format_compact_decimal(1000, format_type='long', locale='it')
'mille'  # previously 'mille1'
>>> numbers.format_decimal(1, format="mille")
'mille'  # previously 'mille1'
>>> format_compact_decimal(21098765, format_type="long", locale="mk")
'21 милиони'  # previously '21 милион' (would still be singular if the number were 21000000)
>>> numbers.format_compact_decimal(1000, format_type='long', locale='fr')
'mille'  # previously '1 millier'

@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #932 (0713d3a) into master (a45e25e) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #932      +/-   ##
==========================================
+ Coverage   91.55%   91.57%   +0.01%     
==========================================
  Files          21       21              
  Lines        4241     4247       +6     
==========================================
+ Hits         3883     3889       +6     
  Misses        358      358              
Impacted Files Coverage Δ
babel/numbers.py 97.97% <100.00%> (+0.03%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

Thanks!

@akx akx merged commit 3594836 into python-babel:master Jan 6, 2023
@DenverCoder1 DenverCoder1 deleted the fix-931-singular-formats-and-apply-with-no-number branch January 6, 2023 20:34
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.

format_compact_decimal incorrectly works when the pattern has no 0 characters

2 participants