Skip to main content

Python flexible slugify module

Project description

Python flexible slugify module


pip install awesome-slugify

Function args


text                  # text for translate. position arg
max_length = None     # output string max length
separator = '-'       # separator string
capitalize = False    # upper first letter if True

Retuns translated text.


pretranslate = None               # function or dict for replace before translation
translate = unidecode.unidecode   # function for slugifying or None
# + slugify's keyword args

Returns slugify function.


from slugify import slugify, get_slugify, slugify_unicode, slugify_ru

slugify('one kožušček')                       # one-kozuscek
slugify('one-=-two-%-three', separator='.')   # one.two.three
slugify('one two Three', capitalize=True)     # One-two-Three
slugify('one two three four', max_length=12)  # one-two-four   (12 chars)

slugify('я ♥ борщ')                           # ia-borshch
slugify_unicode('я ♥ борщ')                   # я-борщ    (sanitize only)

my_slugify = get_slugify(pretranslate={'я': 'i', '♥': 'love', 'щ': 'sch'}, separator='.')
my_slugify('я ♥ борщ')                        #  (custom translate)

slugify_ru('я ♥ борщ')                        # ya-borsch  (alternative russian translation)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awesome-slugify-1.0.2.tar.gz (3.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page