Skip to content

Honor the locale decimal separator in naturalsize() - #463

Open
ekanshul wants to merge 1 commit into
python-humanize:mainfrom
ekanshul:fix-460-naturalsize-locale-decimal
Open

ekanshul wants to merge 1 commit into
python-humanize:mainfrom
ekanshul:fix-460-naturalsize-locale-decimal

Conversation

@ekanshul

Copy link
Copy Markdown

Fixes #460

Changes proposed in this pull request:

  • Use decimal_separator() in naturalsize() so locales with a comma radix (fr_FR, de_DE, it_IT, …) render 1,5 Mo instead of 1.5 Mo
  • Skip the rewrite when the separator is "." so the default English path stays a single format + concat
  • Add a filesize regression test and update the existing French i18n expectations

intcomma() and intword() already honor decimal_separator(). #378 left naturalsize as the remaining loose end.

intcomma() and intword() already swap "." for decimal_separator().
naturalsize() left the mantissa dotted, so fr_FR / de_DE / it_IT
showed "1.5 Mo" instead of "1,5 Mo". Rewrite only when the locale
separator is not ".", so the default English path stays a single
format + concat.

Fixes python-humanize#460
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.

naturalsize() ignores the locale decimal separator

1 participant