Code

Opened 6 years ago

Closed 3 years ago

#6392 closed New feature (fixed)

django.contrib.humanize should be locale aware

Reported by: telenieko Owned by: jezdez
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 5 years ago.
An initial patch
6392.diff (6.5 KB) - added by jezdez 4 years ago.
Updated patch which uses locale-aware formatting.
6392.2.diff (6.5 KB) - added by dmclain 3 years ago.
Slight tweak to get patch to apply cleanly

Download all attachments as: .zip

Change History (14)

comment:1 Changed 6 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

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

Changed 5 years ago by hlian

An initial patch

comment:2 Changed 5 years ago by hlian

  • Has patch set
  • Owner changed from nobody to hlian
  • Status changed from new to assigned

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 5 years ago by garcia_marc

  • Keywords i18n-rf added

comment:4 Changed 4 years ago by jezdez

  • Component changed from Contrib apps to Internationalization
  • Owner changed from hlian to jezdez
  • Patch needs improvement set
  • Status changed from assigned to new
  • Triage Stage changed from Design decision needed to Accepted

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

Changed 4 years ago by jezdez

Updated patch which uses locale-aware formatting.

comment:5 Changed 4 years ago by jezdez

  • Patch needs improvement unset

comment:6 Changed 4 years ago by jezdez

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

comment:7 Changed 3 years ago by jezdez

  • Keywords i18n-rf removed

comment:8 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:9 Changed 3 years ago by patchhammer

  • Easy pickings unset
  • Patch needs improvement set

6392.diff fails to apply cleanly on to trunk

Changed 3 years ago by dmclain

Slight tweak to get patch to apply cleanly

comment:10 Changed 3 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 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

In [16168]:

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.