Created
July 4, 2015 11:14
-
-
Save deliro/01851103f7a0206fe66d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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