#NEWLINE# def render( self , context , nested = False ) : #NEWLINE# #INDENT# if self . message_context : #NEWLINE# #INDENT# message_context = self . message_context . resolve ( context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# message_context = None #NEWLINE# #UNINDENT# tmp_context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( var , val ) in self . extra_context . items ( ) : #NEWLINE# #INDENT# tmp_context [ var ] = val . resolve ( context ) #NEWLINE# #UNINDENT# context . update ( tmp_context ) #NEWLINE# ( singular , vars ) = self . render_token_list ( self . singular ) #NEWLINE# if ( self . plural and self . countervar and self . counter ) : #NEWLINE# #INDENT# count = self . counter . resolve ( context ) #NEWLINE# context [ self . countervar ] = count #NEWLINE# ( plural , plural_vars ) = self . render_token_list ( self . plural ) #NEWLINE# if message_context : #NEWLINE# #INDENT# result = translation . npgettext ( message_context , singular , plural , count ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = translation . ungettext ( singular , plural , count ) #NEWLINE# #UNINDENT# vars . extend ( plural_vars ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if message_context : #NEWLINE# #INDENT# result = translation . pgettext ( message_context , singular ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = translation . ugettext ( singular ) #NEWLINE# #UNINDENT# #UNINDENT# data = dict ( [ ( v , _render_value_in_context ( context . get ( v , '' ) , context ) ) for v in vars ] ) #NEWLINE# context . pop ( ) #NEWLINE# try : #NEWLINE# #INDENT# result = ( result % data ) #NEWLINE# #UNINDENT# except ( KeyError , ValueError ) : #NEWLINE# #INDENT# if nested : #NEWLINE# #INDENT# raise TemplateSyntaxError ( ( "'blocktrans' is unable to format string returned by gettext: %r using %r" % ( result , data ) ) ) #NEWLINE# #UNINDENT# with translation . override ( None ) : #NEWLINE# #INDENT# result = self . render ( context , nested = True ) #NEWLINE# #UNINDENT# #UNINDENT# return result