Skip to content

Use the locale decimal separator in precisedelta - #539

Open
Yasser-Ameur wants to merge 1 commit into
python-humanize:mainfrom
Yasser-Ameur:fix/precisedelta-decimal-separator
Open

Yasser-Ameur wants to merge 1 commit into
python-humanize:mainfrom
Yasser-Ameur:fix/precisedelta-decimal-separator

Conversation

@Yasser-Ameur

Copy link
Copy Markdown

Changes proposed in this pull request:

  • precisedelta formats its fractional value with %, which always prints a dot, so a decimal comma locale gets a dot inside an otherwise translated sentence, while intword and intcomma already use the locale's separator:

    >>> i18n.activate("de_DE")
    >>> humanize.precisedelta(3661.5)
    '1 Stunde, 1 Minute und 1.50 Sekunden'   # before
    '1 Stunde, 1 Minute und 1,50 Sekunden'   # now
    >>> humanize.intword(1_500_000)
    '1,5 Millionen'
  • The value is now formatted first and the dot replaced with decimal_separator(), the approach intword uses. English and the locales whose separator is a dot give the same output as before, and a custom format such as "%0.1f" is still honoured.

  • Adds test_precisedelta_i18n_decimal_separator for en_US, de_DE, fr_FR and es_ES. The de_DE and fr_FR cases fail on main.

  • naturalsize has the same gap (naturalsize() ignores the locale decimal separator #460) and is not touched here.

`precisedelta` printed a dot as the decimal separator in every locale, for example "1.50 Sekunden" under de_DE, while `intword` and `intcomma` already use `decimal_separator()` for the active locale.

The fractional value of the minimum unit was substituted into the translated text through `%` formatting, which always yields a dot. Format the number first, swap the dot for `decimal_separator()` as `intword` does, and substitute the result with `%s`. English output and locales that use a dot are unchanged.
@agentscanapp

agentscanapp Bot commented Dec 2, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Evidence
  • Very high PR volume (daily): 33 PRs within a single 24-hour window, 1 of them to repos it can push to
  • Multiple forks: 5 repositories forked in a single 24-hour window
  • 24/7 activity pattern: Active in 21 of 24 hours, with the longest break being only 3.0 hours

Last 5 PRs:

This is an automated analysis by AgentScan

@Yasser-Ameur
Yasser-Ameur marked this pull request as ready for review December 2, 2026 15:30
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.

1 participant