Skip to content
Browse files

Warning instead of failing when (un)slugify is called without language.

  • Loading branch information
felixfontein committed Mar 6, 2016
1 parent cd17877 commit f5816a8b9ee7ee571cfb3ad7d6529eeabe551bbb
Showing with 6 additions and 2 deletions.
  1. +6 −2 nikola/
@@ -743,7 +743,7 @@ def remove_file(source):
_slugify_hyphenate_re = re.compile(r'[-\s]+')

def slugify(value, lang, force=False):
def slugify(value, lang=None, force=False):
u"""Normalize string, convert to lowercase, remove non-alpha characters, convert spaces to hyphens.
From Django's "django/template/".
@@ -757,6 +757,8 @@ def slugify(value, lang, force=False):
>>> print(slugify('foo bar', lang='en'))
if lang is None:
LOGGER.warn("slugify() called without language!")
if not isinstance(value, unicode_str):
raise ValueError("Not a unicode object: {0}".format(value))
if USE_SLUGIFY or force:
@@ -781,12 +783,14 @@ def slugify(value, lang, force=False):
return value

def unslugify(value, lang, discard_numbers=True):
def unslugify(value, lang=None, discard_numbers=True):
"""Given a slug string (as a filename), return a human readable string.
If discard_numbers is True, numbers right at the beginning of input
will be removed.
if lang is None:
LOGGER.warn("unslugify() called without language!")
if discard_numbers:
value = re.sub('^[0-9]+', '', value)
value = re.sub('([_\-\.])', ' ', value)

0 comments on commit f5816a8

Please sign in to comment.
You can’t perform that action at this time.