Opened 9 years ago

Closed 9 years ago

#25920 closed New feature (fixed)

Add number formatting support for locales that use non-uniform digit grouping (e.g. India)

Reported by: Binoj David Owned by: Szymon Teżewski
Component: Internationalization Version: 1.9
Severity: Normal Keywords: en-IN
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using 'en-IN' as locale (listed as valid in http://www.i18nguy.com/unicode/language-identifiers.html) 100000.00 should look like 1,00,000.00 after using intcomma. Instead 100,000.00 is displayed.

Works as expected in locale package as below (with en_IN installed, of course):

In [1]: import locale

In [2]: locale.setlocale(locale.LC_ALL, 'en_IN')
Out[2]: 'en_IN'

In [3]: locale.format("%.2f", 100000.00, grouping=True)
Out[3]: '1,00,000.00'

Change History (11)

comment:1 by Tim Graham, 9 years ago

Resolution: invalid
Status: newclosed

I think the solution here is to add formats for the en_IN locale (like ff2e0896a3f7b566c8a0802b2191d30c6070c8f6, for example). Please send a pull request if you can do that. I don't think there's much value in leaving an open ticket for each locale that we're missing. Thanks!

comment:2 by Binoj David, 9 years ago

Resolution: invalid
Status: closednew

There is a complication in adding en_IN. Number grouping in en_IN is not grouped on 'n' number of digits. First 3 (ones, tens and hundreds) are grouped as a single group and the remaining digits are grouped as 2 digits per group. This can be achieved with a NUMBER_GROUPING setting. So I don't think this can be fixed by adding a locale. I'm happy to help with a PR for the locale though, if there is a way to solve this problem.

Version 2, edited 9 years ago by Binoj David (previous) (next) (diff)

comment:3 by Claude Paroz, 9 years ago

Triage Stage: UnreviewedAccepted
Type: BugNew feature

Confirmed, Django doesn't support this sort of grouping yet.

comment:4 by Tim Graham, 9 years ago

Component: contrib.humanizeInternationalization
Summary: django.contrib.humanize filters are not well localized for en_INAdd number formatting support for locales that use non-uniform digit grouping (e.g. India)

comment:5 by Szymon Teżewski, 9 years ago

Owner: changed from nobody to Szymon Teżewski
Status: newassigned

comment:6 by Szymon Teżewski, 9 years ago

Has patch: set

comment:7 by Szymon Teżewski, 9 years ago

PR for this: https://github.com/django/django/pull/6693
It basically adds possibility to use more robust NUMBER_GROUPING using style similar to POSIX locale grouping option.

comment:8 by Philip James, 9 years ago

Triage Stage: AcceptedReady for checkin

I looked at the pull request, and think it looks RTC for the following reasons:

  • Has tests
  • Test suite passes
  • Old functionality from previous tests remains unchanged.

comment:9 by Tim Graham, 9 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

A bit of documentation is missing as noted on the PR.

comment:10 by Tim Graham, 9 years ago

Patch needs improvement: unset

comment:11 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In b5a1c3a:

Fixed #25920 -- Added support for non-uniform NUMBER_GROUPING.

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