Skip to content

Commit 1138b2a

Browse files
committed
Update django compatibility
1 parent d3e1bf7 commit 1138b2a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

django_babel/extract.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.template import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
33
from django.utils.translation.trans_real import (
44
inline_re, block_re, endblock_re, plural_re, constant_re)
5-
from django.utils.encoding import smart_unicode
5+
from django.utils.encoding import smart_text
66

77

88
def extract_django(fileobj, keywords, comment_tags, options):
@@ -38,14 +38,14 @@ def extract_django(fileobj, keywords, comment_tags, options):
3838
yield (
3939
lineno,
4040
'ngettext',
41-
(smart_unicode(u''.join(singular)),
42-
smart_unicode(u''.join(plural))),
41+
(smart_text(u''.join(singular)),
42+
smart_text(u''.join(plural))),
4343
[])
4444
else:
4545
yield (
4646
lineno,
4747
None,
48-
smart_unicode(u''.join(singular)),
48+
smart_text(u''.join(singular)),
4949
[])
5050

5151
intrans = False
@@ -78,22 +78,22 @@ def extract_django(fileobj, keywords, comment_tags, options):
7878
g = g.strip('"')
7979
elif g[0] == "'":
8080
g = g.strip("'")
81-
yield lineno, None, smart_unicode(g), []
81+
yield lineno, None, smart_text(g), []
8282
elif bmatch:
8383
for fmatch in constant_re.findall(t.contents):
84-
yield lineno, None, smart_unicode(fmatch), []
84+
yield lineno, None, smart_text(fmatch), []
8585
intrans = True
8686
inplural = False
8787
singular = []
8888
plural = []
8989
elif cmatches:
9090
for cmatch in cmatches:
91-
yield lineno, None, smart_unicode(cmatch), []
91+
yield lineno, None, smart_text(cmatch), []
9292
elif t.token_type == TOKEN_VAR:
9393
parts = t.contents.split('|')
9494
cmatch = constant_re.match(parts[0])
9595
if cmatch:
96-
yield lineno, None, smart_unicode(cmatch.group(1)), []
96+
yield lineno, None, smart_text(cmatch.group(1)), []
9797
for p in parts[1:]:
9898
if p.find(':_(') >= 0:
9999
p1 = p.split(':', 1)[1]
@@ -105,4 +105,4 @@ def extract_django(fileobj, keywords, comment_tags, options):
105105
p1 = p1.strip("'")
106106
elif p1[0] == '"':
107107
p1 = p1.strip('"')
108-
yield lineno, None, smart_unicode(p1), []
108+
yield lineno, None, smart_text(p1), []

0 commit comments

Comments
 (0)