Code

Opened 2 years ago

Closed 14 months ago

#17217 closed Bug (fixed)

Set nbsp instead of space as thousand separator

Reported by: fadeyev Owned by: nobody
Component: Translations Version:
Severity: Normal Keywords:
Cc: sun.void@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Space was replaced with nbsp only for Polish locale: https://code.djangoproject.com/ticket/13577
I wonder why it hasn't been done for all other locales that use a space as a thousand separator.

Attachments (2)

set_nbsp_instead_of_space_as_a_thousand_separator.diff (3.1 KB) - added by fadeyev 2 years ago.
17217-2.diff (3.9 KB) - added by claudep 2 years ago.
Also update docs/topics/i18n/formatting.txt

Download all attachments as: .zip

Change History (12)

comment:1 Changed 2 years ago by aaugustin

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

I'd be nice to check the typographical conventions of the 8 countries involved in this patch, just to be sure that NBSP is the proper character — there are other variants of SP.

That said, I can't imagine a reason why a SP would be better than a NBSP as thousand separator. The only difference is that the latter prevents line wrapping, and line wrapping in the middle of a number can't be correct. So, even if NBSP isn't the sanctioned character, I'd still be better than SP.

If we wanted to follow this logic entirely, we should also patch docs/topics/i18n/formatting.txt.

Last edited 2 years ago by aaugustin (previous) (diff)

Changed 2 years ago by claudep

Also update docs/topics/i18n/formatting.txt

comment:2 Changed 2 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 2 years ago by jezdez

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

In [17478]:

Fixed #17217 -- Use non breaking spaces for format localization in which spaces are used. Thanks, Claude Paroz.

comment:4 Changed 14 months ago by void

  • Resolution fixed deleted
  • Status changed from closed to new

One thing that had not been considered when that patch was applied is that thousand separator is used not only for formatting, but in forms input too. It is rather hard to force users to use non-breaking space when they input numbers.
Probably we should have one setting for formatting and another for forms validation.

comment:5 Changed 14 months ago by void

  • Cc sun.void@… added

comment:6 Changed 14 months ago by claudep

Yeah, this striked me too, some days ago. Wouldn't non-breaking space common enough to justify some special-casing when validating inputs?

comment:7 Changed 14 months ago by void

I think about using unicodedata module. Non-breaking space normalizes to normal space:

>>> import unicodedata
>>> unicodedata.normalize('NFKD', u'\xa0')
u' '

This way we can determine that non-breaking and usual spaces are roughly the same. So we can special-case non-breaking space without actually hardcoding it -)

comment:8 Changed 14 months ago by void

I've created a pull request, please review: https://github.com/django/django/pull/726

comment:9 Changed 14 months ago by Claude Paroz <claude@…>

In b19d83fc12ebbabbaa9d72286f2e4bfa071ff784:

Improved input sanitizing with thousand separators

For languages with non-breaking space as thousand separator,
standard space input should also be allowed, as few people know
how to enter non-breaking space on keyboards. Refs #17217.
Thanks Alexey Boriskin for the report and initial patch.

comment:10 Changed 14 months ago by claudep

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

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.