Exemple #1
0
 def render(self, context):
     value = self.value.resolve(context)
     if self.noop:
         return value
     else:
         return _render_value_in_context(translation.ugettext(value),
                                         context)
Exemple #2
0
 def render(self, context):
     tmp_context = {}
     for var, val in self.extra_context.items():
         tmp_context[var] = val.render(context)
     # Update() works like a push(), so corresponding context.pop() is at
     # the end of function
     context.update(tmp_context)
     singular, vars = self.render_token_list(self.singular)
     if self.plural and self.countervar and self.counter:
         count = self.counter.resolve(context)
         context[self.countervar] = count
         plural, vars = self.render_token_list(self.plural)
         result = translation.ungettext(singular, plural, count)
     else:
         result = translation.ugettext(singular)
     # Escape all isolated '%' before substituting in the context.
     result = re.sub(u'%(?!\()', u'%%', result)
     data = dict([(v, _render_value_in_context(context[v], context)) for v in vars])
     context.pop()
     return result % data
Exemple #3
0
 def render(self, context):
     self.filter_expression.var.translate = not self.noop
     output = self.filter_expression.resolve(context)
     return _render_value_in_context(output, context)
Exemple #4
0
 def render(self, context):
     value = self.value.resolve(context)
     if self.noop:
         return value
     else:
         return _render_value_in_context(translation.ugettext(value), context)
Exemple #5
0
 def render(self, context):
     self.filter_expression.var.translate = not self.noop
     output = self.filter_expression.resolve(context)
     return _render_value_in_context(output, context)