Repository navigation
Conversation
Ekko82
left a comment
There was a problem hiding this comment.
The new fractional-byte branch drops the translated unit label.
Reproduced on Windows with Python 3.13.9 at c18458aaa04cfac2d434b42f51573b4428909f0a, using the actual filesize and i18n modules and the checked-in French catalog compiled with Babel. The English/GNU fractional cases preserve their fractions, and integer French outputs remain unchanged. The full suite and package builds were not run.
| if bytes_.is_integer(): | ||
| return f"{int(bytes_)}B" if gnu else _("%d Bytes") % int(bytes_) | ||
| formatted_bytes = format % bytes_ | ||
| return f"{formatted_bytes}B" if gnu else f"{formatted_bytes} Bytes" |
There was a problem hiding this comment.
Non-GNU fractional values bypass _() here and always receive the English label Bytes. With the real fr_FR catalog active:
from humanize.filesize import naturalsize
from humanize.i18n import activate
activate("fr_FR")
naturalsize(2) # '2 octets'
naturalsize(1.5) # '1.5 Bytes'The base returned '1 octets' for the fractional call, so preserving the fraction now drops its existing unit translation. Negative fractions and binary=True take the same path. Please retain a translatable message for this branch and add a compiled-catalog regression.
Summary
Testing
py -3.13 -m pytest -q— 746 passed, 112 skipped.git diff --check— passed.