Skip to content

Use a comma as the fr_FR decimal separator - #378

Merged
hugovk merged 1 commit into
python-humanize:mainfrom
ckarnell:fix-fr-decimal-separator
Sep 16, 2026
Merged

hugovk merged 1 commit into
python-humanize:mainfrom
ckarnell:fix-fr-decimal-separator

Conversation

@ckarnell

Copy link
Copy Markdown
Contributor

fr_FR is the only entry in _DECIMAL_SEPARATOR with a dot. Every other locale there pairs a group separator with a comma, including hu_HU and lv, which group with a space exactly like French does.

humanize.i18n.activate("fr_FR")
humanize.intcomma(1_234_567.89)   # "1 234 567.89", want "1 234 567,89"
humanize.intword(1_000)           # "1.0 mille",    want "1,0 mille"

You already worked this out in #357: the dot came from #248, and merwok said French needs the comma. That PR was closed by its author before it landed. So the value is still there.

One line of data. Plus the 26 fr_FR expectations that encoded the old output.

naturalsize is deliberately untouched, and it is the one loose end. filesize.py never reads the separator, so it still prints 42.0 Ko while intcomma now prints a comma. #357 tried to fix both together and picked up a 10% performance report on the bundle, so this leaves that half alone. Happy to send it separately if you want it, and it's a fair reason to hold this one.

Tests are 789 passing before and after, same set. Reverting just the i18n.py line fails exactly the 26 updated expectations and nothing else, so the tests are pinned to the change, not to the diff.

@Mukller Mukller left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified locally on the PR branch (Python 3.13): pytest tests/test_i18n.py6 passed, including the updated fr_FR assertions for both intcomma (1 234 567,89) and the full naturaldelta matrix (1,0 mille1,0 milliard).

The substance is unambiguous: French uses the comma as its decimal separator (per standard French typography and every other locale entry in that same mapping), so "." in _DECIMAL_SEPARATOR["fr_FR"] was simply wrong. This PR aligns fr_FR with de_DE/it_IT/pt_BR/hu_HU rather than introducing anything novel.

One note for the changelog: this changes every fr_FR-formatted decimal output at once — downstream consumers who (incorrectly) parsed humanize's French output against the old dot will see different strings. Worth an explicit line as a behavior fix.

Approving.

Mukller

This comment was marked as duplicate.

fr_FR was the only locale in the table pairing a group separator with a
dot decimal mark. French uses the comma, so intcomma and intword printed
1 234 567.89 instead of 1 234 567,89.

naturalsize is unchanged because filesize.py does not read the separator.
@hugovk
hugovk force-pushed the fix-fr-decimal-separator branch from 23e1602 to 9b579cd Compare September 16, 2026 15:23
@hugovk
hugovk enabled auto-merge (squash) September 16, 2026 15:24
@hugovk

hugovk commented Sep 16, 2026

Copy link
Copy Markdown
Member

Merci!

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.56%. Comparing base (2ad3641) to head (9b579cd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #378   +/-   ##
=======================================
  Coverage   99.56%   99.56%           
=======================================
  Files          12       12           
  Lines         927      927           
=======================================
  Hits          923      923           
  Misses          4        4           
Flag Coverage Δ
macos-latest 97.62% <100.00%> (ø)
ubuntu-latest 97.62% <100.00%> (ø)
windows-latest 95.46% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hugovk hugovk added the changelog: Fixed For any bug fixes label Sep 16, 2026
@hugovk
hugovk merged commit 57fbacc into python-humanize:main Sep 16, 2026
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: Fixed For any bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants