#NEWLINE# @ register . tag ( 'localize' ) #NEWLINE# def localize_tag( parser , token ) : #NEWLINE# #INDENT# '\n    Forces or prevents localization of values, regardless of the value of\n    `settings.USE_L10N`.\n\n    Sample usage::\n\n        {% localize off %}\n            var pi = {{ 3.1415 }};\n        {% endlocalize %}\n\n    ' #NEWLINE# use_l10n = None #NEWLINE# bits = list ( token . split_contents ( ) ) #NEWLINE# if ( len ( bits ) == 1 ) : #NEWLINE# #INDENT# use_l10n = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( len ( bits ) > 2 ) or ( bits [ 1 ] not in ( 'on' , 'off' ) ) ) : #NEWLINE# #INDENT# raise TemplateSyntaxError ( ( "%r argument should be 'on' or 'off'" % bits [ 0 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# use_l10n = ( bits [ 1 ] == 'on' ) #NEWLINE# #UNINDENT# #UNINDENT# nodelist = parser . parse ( ( 'endlocalize' , ) ) #NEWLINE# parser . delete_first_token ( ) #NEWLINE# return LocalizeNode ( nodelist , use_l10n )