예제 #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)
예제 #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
예제 #3
0
파일: i18n.py 프로젝트: 0xmilk/appscale
 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)
예제 #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)
예제 #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)