diff --git a/django_babel/extract.py b/django_babel/extract.py index 209761e..1cd92a4 100644 --- a/django_babel/extract.py +++ b/django_babel/extract.py @@ -33,7 +33,14 @@ def extract_django(fileobj, keywords, comment_tags, options): encoding = options.get('encoding', 'utf8') text = fileobj.read().decode(encoding) - for t in Lexer(text, None).tokenize(): + try: + text_lexer = Lexer(text) + except TypeError: + # Django 1.9 changed the way we invoke Lexer; older versions + # require two parameters. + text_lexer = Lexer(text, None) + + for t in text_lexer.tokenize(): lineno += t.contents.count('\n') if intrans: if t.token_type == TOKEN_BLOCK: