1- from __future__ import unicode_literals
2-
31import re
4- from django .utils .translation import ugettext
2+ from django .utils .translation import gettext
53from .conf import conf
64
5+
76class I18nPreprocessor (object ):
87 @property
98 def tagnames (self ):
@@ -13,7 +12,7 @@ def tagnames(self):
1312 def short_trans_re (self ):
1413 # Should match strings like: {{ _ "Hello, world! }}
1514 tagnames = '|' .join (['(?:{0})' .format (t ) for t in self .tagnames ])
16-
15+
1716 left_side = r'''(?P<left>\{\{\s*(?P<tag>(?:''' + tagnames + r''')\s+)(?P<quote>['"]))'''
1817 right_side = r'''(?P<right>(?P=quote)\s*\}\})'''
1918
@@ -23,7 +22,7 @@ def short_trans_re(self):
2322 def long_trans_re (self ):
2423 # Should match strings like: {{# _ }}Hello, {{ name }}.{{/ _ }}
2524 tagnames = '|' .join (['(?:{0})' .format (t ) for t in self .tagnames ])
26-
25+
2726 start_tag = r'\{\{#\s*(?P<tag>' + tagnames + r')\s*\}\}'
2827 end_tag = r'\{\{\/\s*(?P=tag)\s*\}\}'
2928
@@ -33,14 +32,14 @@ def translate_short_form(self, match):
3332 """Translate a result of matching the compiled trans_re pattern."""
3433 tag = match .group ('tag' )
3534 msg = match .group ('msg' )
36- msg = ugettext (msg ) if len (msg ) > 0 else ''
35+ msg = gettext (msg ) if len (msg ) > 0 else ''
3736 string = match .group ('left' ).replace (tag , '' , 1 ) + msg + match .group ('right' )
3837 return string
3938
4039 def translate_long_form (self , match ):
4140 """Translate a result of matching the compiled trans_re pattern."""
4241 msg = match .group ('msg' )
43- string = ugettext (msg ) if len (msg ) > 0 else ''
42+ string = gettext (msg ) if len (msg ) > 0 else ''
4443 return string
4544
4645 def process (self , content ):
0 commit comments