Code

Opened 7 years ago

Closed 7 years ago

#3631 closed (wontfix)

the built-in truncatewords filter can't deal with chinese

Reported by: anonymous Owned by: jacob
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

i've tried to use the built-in the built-in truncatewords filter,
but it seems that it can not recognize Chinese characters.
As well as the wordcount filter has the same problem too.
No matter what the str is, the wordcount filter will return 1.

BTW, the str variable is utf-8 encoded, and i can use the len() method to get the correct length.

Thanks..

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

I have zero knowledge of Chinese, so I ask: does Chinese use normal spaces in between "words"? The filter uses len(value.split()) to count the words, and if the .split() isn't working then the problem is obvious.

Since that is all the built-in filter does, I don't think there's anything we can do to make it work for special language cases. Better to write your own filter that works (and perhaps submit it as an enhancement)

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.