Opened 18 years ago
Closed 17 years ago
#2276 closed enhancement (duplicate)
[patch] make slugify filter to be aware of unicode
Reported by: | nkeric | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently the slugify filter only works with english alphanumeric characters, here is a simple patch that makes it to be able to "match the characters [0-9_] plus whatever is classified as alphanumeric in the Unicode character properties database".
here is the ref:
http://docs.python.org/lib/re-syntax.html
http://docs.python.org/lib/node115.html
Regards,
- Eric
Attachments (6)
Change History (13)
by , 18 years ago
Attachment: | defaultfilters.py.diff added |
---|
comment:1 by , 18 years ago
by , 18 years ago
Attachment: | defaultfilters.py.2.diff added |
---|
new diff with re.U replaced with re.UNICODE
by , 18 years ago
Attachment: | defaultfilters.py.3.diff added |
---|
output string should be utf-8 encoded as input string
by , 18 years ago
Attachment: | validators.py.2.diff added |
---|
decode utf-8 encoded string for doing re search
comment:4 by , 17 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
I found this program: Slughifi is slugify with support for international characters.
http://amisphere.com/contrib/python-django/
http://amisphere.com/contrib/python-django/slughifi.py
comment:5 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Somebody brought that up on the mailing list at one point. Further investigation revealed is was under the GPL license (no license is mentioned in the file, which is even worse), so we cannot use it.
We have a different solution in the works over at #4365 which I'll resolve in the near future.
comment:6 by , 17 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
By now, I found a solution.
Got from http://www.djangosnippets.org/snippets/98/ (_string_to_slug method) that points to
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/251871 (Aaron Bentley)
E.g: It translates: Á È ï ô ü ñ to: A E i o u n
so it's very usefull for a lot of languages.
I add a patch.
comment:7 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Closing in favor of #4365
I tested it and it handles Chinese Characters properly (should work with other language's characters too), and all Chinese punctuations are removed as expected :)