Opened 9 years ago

Closed 5 years ago

#6392 closed New feature (fixed)

django.contrib.humanize should be locale aware

Reported by: Marc Fargas Owned by: Jannis Leidel
Component: Internationalization Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX:

Description

Currently "humanize" assumes that the decimal separator is "." and "," for (dunno name) what you put every three digits.
In some languages (europe) it's just the reverse. Maybe 'humanize' could be aware of the current language. Otherwise humanize is nonsense on Europe and almost anywhere outside US ;)

Attachments (3)

humanize-numbers-locale.patch (5.3 KB) - added by hlian 8 years ago.
An initial patch
6392.diff (6.5 KB) - added by Jannis Leidel 7 years ago.
Updated patch which uses locale-aware formatting.
6392.2.diff (6.5 KB) - added by dmclain 5 years ago.
Slight tweak to get patch to apply cleanly

Download all attachments as: .zip

Change History (14)

comment:1 Changed 9 years ago by Chris Beaven

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed

It would probably be easy enough to have the decimal and thousands separators translated.

Changed 8 years ago by hlian

An initial patch

comment:2 Changed 8 years ago by hlian

Has patch: set
Owner: changed from nobody to hlian
Status: newassigned

Here's an initial patch. I only have access to a Linux machine via a virtual machine, so I'd appreciate it if somebody with a non-en_US locale that implements different thousands/decimal separators could run the test and verify that it works.

I think this ticket conflicts with #9037.

comment:3 Changed 8 years ago by Marc Garcia

Keywords: i18n-rf added

comment:4 Changed 7 years ago by Jannis Leidel

Component: Contrib appsInternationalization
Owner: changed from hlian to Jannis Leidel
Patch needs improvement: set
Status: assignednew
Triage Stage: Design decision neededAccepted

Ok, the patch needs an update after we added locale-aware formatting.

Changed 7 years ago by Jannis Leidel

Attachment: 6392.diff added

Updated patch which uses locale-aware formatting.

comment:5 Changed 7 years ago by Jannis Leidel

Patch needs improvement: unset

comment:6 Changed 7 years ago by Jannis Leidel

I'm still not entirely sure if this is the right approach, any ideas would be much appreciated.

comment:7 Changed 6 years ago by Jannis Leidel

Keywords: i18n-rf removed

comment:8 Changed 5 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:9 Changed 5 years ago by patchhammer

Easy pickings: unset
Patch needs improvement: set

6392.diff fails to apply cleanly on to trunk

Changed 5 years ago by dmclain

Attachment: 6392.2.diff added

Slight tweak to get patch to apply cleanly

comment:10 Changed 5 years ago by dmclain

Patch needs improvement: unset

Looking over the patch, I'm not sure what, if anything is wrong with the approach. It seems like doing correct humanization across languages is a big win.

comment:11 Changed 5 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [16168]:

Fixed #6392 -- Made django.contrib.humanize template tags locale aware. Thanks, Dave McLain.

Note: See TracTickets for help on using tickets.
Back to Top