Skip to content

Instantly share code, notes, and snippets.

@lovevn
Created December 14, 2012 08:30
Show Gist options
  • Save lovevn/4283650 to your computer and use it in GitHub Desktop.
Save lovevn/4283650 to your computer and use it in GitHub Desktop.
Generating Slugs for Vietnamese language
# this gist get from
#http://flask.pocoo.org/snippets/5/
import re
from unidecode import unidecode
_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
def slugify(text, delim=u'-'):
"""Generates an ASCII-only slug."""
result = []
for word in _punct_re.split(text.lower()):
result.extend(unidecode(word).split())
return unicode(delim.join(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment