Opened 8 years ago

Closed 5 years ago

#9037 closed New feature (fixed)

django.contrib.humanize new filter (dotint)

Reported by: Wiliam Alves de Souza Owned by: nobody
Component: contrib.humanize Version: master
Severity: Normal Keywords: contrib humanize
Cc: semente@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Converts an integer to a string containing dots every three digits. In Brazil we use dot not commas to separate numbers and is possible other location around the world use it too.

Attachments (2)

humanize_intdot.diff (2.4 KB) - added by Wiliam Alves de Souza 8 years ago.
humanize_intcomma_locale_specific.diff (577 bytes) - added by erickd 8 years ago.

Download all attachments as: .zip

Change History (14)

Changed 8 years ago by Wiliam Alves de Souza

Attachment: humanize_intdot.diff added

comment:1 Changed 8 years ago by Guilherme M. Gondim <semente@…>

Cc: semente@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 8 years ago by Guilherme M. Gondim <semente@…>

Patch needs improvement: set

comment:3 Changed 8 years ago by Malcolm Tredinnick

milestone: post-1.0
Triage Stage: UnreviewedDesign decision needed

This is probably not the right approach for something in core. Rather, we should make the existing filter locale-aware when we put that stuff in (the plan is to include locale data for things like numeric separators and date formats). Then the existing filter will use dots or commas as appropriate for the page's locale.

So I'm -1 on this at the moment.

comment:4 Changed 8 years ago by Wiliam Alves de Souza

Malcolm,
You think an approach like DATE_FORMAT, when each country has the possibility to change the default behavior of date format is the correct? What you think to create some options like NUMERIC, MONETARY, TELEPHONE and MEASUREMENT to be used internally for numeric separators, date formats, monetary values, telephone displaying and validation and measurement.

comment:5 in reply to:  description Changed 8 years ago by finngruwier

Replying to waa:

Converts an integer to a string containing dots every three digits. In Brazil we use dot not commas to separate numbers and is possible other location around the world use it too.

Same in many European locales. The dot is probably used in more locales then the comma.

comment:6 Changed 8 years ago by Justin Lilly

Component: UncategorizedContrib apps

Changed 8 years ago by erickd

comment:7 Changed 8 years ago by anonymous

This issue definitely warrants some more attention in the long run, but how about doing something simple and effective for now (see attached diff). Would this make most people happy?

comment:8 Changed 8 years ago by erickd

This issue definitely warrants some more attention in the long run, but how about doing something simple and effective for now (see attached diff). Would this make most people happy?

comment:9 Changed 8 years ago by Malcolm Tredinnick

If people want something "for now", they are free to include this filter in their code; there is absolutely nothing requiring this to be part of Django. We are not in the habit of intentionally including half-baked solutions in the core code, however. It can wait for the full-scale solution, rather than having people write code using distributed Django that contains something which is already effectively end-of-lifed.

comment:10 Changed 5 years ago by Gabriel Hurley

Component: Contrib appscontrib.humanize

comment:11 Changed 5 years ago by Luke Plant

Severity: Normal
Type: New feature

comment:12 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset
Resolution: fixed
Status: newclosed
UI/UX: unset

This feature is now provided by the THOUSAND_SEPARATOR and NUMBER_GROUPING — from the settings when USE_L10N = False, and each locale's formats.py when USE_L10N = True.

The values for pt_BRare correct:

THOUSAND_SEPARATOR = '.'
NUMBER_GROUPING = 3

All this probably didn't exist when the ticket was opened.

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