#NEWLINE# def do_translate( parser , token ) : #NEWLINE# #INDENT# '\n    This will mark a string for translation and will\n    translate the string for the current language.\n\n    Usage::\n\n        {% trans "this is a test" %}\n\n    This will mark the string for translation so it will\n    be pulled out by mark-messages.py into the .po files\n    and will run the string through the translation engine.\n\n    There is a second form::\n\n        {% trans "this is a test" noop %}\n\n    This will only mark for translation, but will return\n    the string unchanged. Use it when you need to store\n    values into forms that should be translated later on.\n\n    You can use variables instead of constant strings\n    to translate stuff you marked somewhere else::\n\n        {% trans variable %}\n\n    This will just try to translate the contents of\n    the variable ``variable``. Make sure that the string\n    in there is something that is in the .po file.\n    ' #NEWLINE# class TranslateParser ( TokenParser ) : #NEWLINE# #INDENT# def top( self ) : #NEWLINE# #INDENT# value = self . value ( ) #NEWLINE# if ( value [ 0 ] == "'" ) : #NEWLINE# #INDENT# pos = None #NEWLINE# m = re . match ( "^'([^']+)'(\\|.*$)" , value ) #NEWLINE# if m : #NEWLINE# #INDENT# value = ( '"%s"%s' % ( m . group ( 1 ) . replace ( '"' , '\\"' ) , m . group ( 2 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( value [ ( - 1 ) ] == "'" ) : #NEWLINE# #INDENT# value = ( '"%s"' % value [ 1 : ( - 1 ) ] . replace ( '"' , '\\"' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . more ( ) : #NEWLINE# #INDENT# if ( self . tag ( ) == 'noop' ) : #NEWLINE# #INDENT# noop = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TemplateSyntaxError ( "only option for 'trans' is 'noop'" ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# noop = False #NEWLINE# #UNINDENT# return ( value , noop ) #NEWLINE# #UNINDENT# #UNINDENT# ( value , noop ) = TranslateParser ( token . contents ) . top ( ) #NEWLINE# return TranslateNode ( parser . compile_filter ( value ) , noop )