mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add unidecode for translating slugs in asian languages
This commit is contained in:
parent
18019efd38
commit
6f40e452e1
3 changed files with 6 additions and 2 deletions
|
|
@ -49,6 +49,8 @@ def slugify(value):
|
|||
value = Markup(value).striptags()
|
||||
if type(value) == unicode:
|
||||
import unicodedata
|
||||
from unidecode import unidecode
|
||||
value = unicode(unidecode(value))
|
||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
|
||||
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
|
||||
return re.sub('[-\s]+', '-', value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue