Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#29654 closed Cleanup/optimization (fixed)

Truncate should use horizontal ellipsis character instead of three dots

Reported by: Sudhanshu Mishra Owned by: nobody
Component: Utilities Version: dev
Severity: Normal Keywords: string, truncator
Cc: Dan Davis 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

In the following example the value returns a string which has a length of 18 and including 3 dots.

>>> from django.utils.text import Truncator
>>> Truncator("Hello world is not so long").chars(18)
'Hello world is ...'
>>> Truncator("Hello world is not so long").chars(18)[-1]
'.'

IMHO, the Truncator should use ... (ellipsis) character instead.

Change History (13)

comment:1 Changed 3 years ago by Sudhanshu Mishra

Has patch: set

comment:2 Changed 3 years ago by Claude Paroz

Component: Template systemUtilities
Patch needs improvement: set
Triage Stage: UnreviewedAccepted
UI/UX: unset
Version: 2.1master

I'd be in favour of this change.

PR

comment:3 Changed 3 years ago by Claude Paroz

But there are many more occurrences in the Django source code and comments. We should be consistent. Does this need a discussion?

comment:4 Changed 3 years ago by Vishvajit Pathak

Sudhanshu,
Do you mean the expected output should be like below :

>>> Truncator("Hello world is not so long").chars(18)[-1]
'...'

comment:5 Changed 3 years ago by Claude Paroz

Patch needs improvement: unset

I added that PR.

comment:6 Changed 3 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:7 Changed 3 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In 201017df:

Fixed #29654 -- Made text truncation an ellipsis character instead of three dots.

Thanks Sudhanshu Mishra for the initial patch and Tim Graham for the review.

comment:8 Changed 3 years ago by Tim Graham <timograham@…>

In 50b84935:

Refs #29654 -- Replaced three dots with ellipsis character in output strings.

comment:9 Changed 3 years ago by Tim Graham <timograham@…>

In 5311a36:

Refs #29654 -- Replaced three dots with ellipsis in DB creation output strings.

comment:10 Changed 3 years ago by Tim Graham

There have been some reports of the ellipses causing crashes on the shell (#30184) so parts of this might be reverted.

comment:11 Changed 3 years ago by Dan Davis

Cc: Dan Davis added

comment:12 Changed 3 years ago by Tim Graham <timograham@…>

In 2bd8df24:

Fixed #30184 -- Removed ellipsis characters from shell output strings.

Partially reverted 50b8493581fea3d7137dd8db33bac7008868d23a (refs #29654)
to avoid a crash when the user shell doesn't support non-ASCII characters.

comment:13 Changed 3 years ago by Tim Graham <timograham@…>

In 5e94c817:

[2.2.x] Fixed #30184 -- Removed ellipsis characters from shell output strings.

Partially reverted 50b8493581fea3d7137dd8db33bac7008868d23a (refs #29654)
to avoid a crash when the user shell doesn't support non-ASCII characters.
Backport of 2bd8df243ac6fc35e58c9fe90b20c9e42519a5ac from master.

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