Skip to content

Instantly share code, notes, and snippets.

@deliro
Created July 4, 2015 11:14
Show Gist options
  • Save deliro/01851103f7a0206fe66d to your computer and use it in GitHub Desktop.
Save deliro/01851103f7a0206fe66d to your computer and use it in GitHub Desktop.
from django.template.defaultfilters import slugify as django_slugify
alphabet = {'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', 'ж': 'zh', 'з': 'z', 'и': 'i',
'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't',
'у': 'u', 'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ы': 'i', 'э': 'e', 'ю': 'yu',
'я': 'ya'}
def slugify(s):
"""
Overriding django slugify that allows to use russian words as well.
"""
return django_slugify(''.join(alphabet.get(w, w) for w in s.lower()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment