|
|
|
@ -7,11 +7,11 @@ import re
|
|
|
|
|
import six |
|
|
|
|
|
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.utils.encoding import force_text, smart_text |
|
|
|
|
from django.utils.encoding import force_str, smart_str |
|
|
|
|
from django.utils.functional import keep_lazy_text |
|
|
|
|
from django.utils.html import mark_safe |
|
|
|
|
from django.utils.text import slugify as django_slugify |
|
|
|
|
from django.utils.translation import ugettext_lazy |
|
|
|
|
from django.utils.translation import gettext_lazy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@keep_lazy_text |
|
|
|
@ -19,7 +19,7 @@ def downgrade(value):
|
|
|
|
|
""" |
|
|
|
|
Downgrade unicode to ascii, transliterating accented characters. |
|
|
|
|
""" |
|
|
|
|
value = force_text(value or "") |
|
|
|
|
value = force_str(value or "") |
|
|
|
|
return codecs.encode(value, 'transliterate') |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,7 +48,7 @@ if six.PY2:
|
|
|
|
|
|
|
|
|
|
def html_entities_to_unicode(html): |
|
|
|
|
# An incoming HTML or XML entity is always converted into the corresponding Unicode character in bs4 |
|
|
|
|
return smart_text(bs4.BeautifulSoup(html), 'lxml') |
|
|
|
|
return smart_str(bs4.BeautifulSoup(html), 'lxml') |
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
import html |
|
|
|
@ -60,10 +60,10 @@ else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Translators: Separator between list elements |
|
|
|
|
DEFAULT_SEPARATOR = ugettext_lazy(", ") |
|
|
|
|
DEFAULT_SEPARATOR = gettext_lazy(", ") |
|
|
|
|
|
|
|
|
|
# Translators: Last separator of list elements |
|
|
|
|
LAST_WORD_SEPARATOR = ugettext_lazy(" and ") |
|
|
|
|
LAST_WORD_SEPARATOR = gettext_lazy(" and ") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@keep_lazy_text |
|
|
|
@ -72,10 +72,10 @@ def get_text_joined(list_, separator=DEFAULT_SEPARATOR, last_word=LAST_WORD_SEPA
|
|
|
|
|
if len(list_) == 0: |
|
|
|
|
return '' |
|
|
|
|
if len(list_) == 1: |
|
|
|
|
return force_text(list_[0]) |
|
|
|
|
return force_str(list_[0]) |
|
|
|
|
return '%s%s%s' % ( |
|
|
|
|
separator.join(force_text(i) for i in list_[:-1]), |
|
|
|
|
force_text(last_word), force_text(list_[-1])) |
|
|
|
|
separator.join(force_str(i) for i in list_[:-1]), |
|
|
|
|
force_str(last_word), force_str(list_[-1])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@keep_lazy_text |
|
|
|
|