def extract_messages_from_code(code, is_py=False):
 try:
  code = render_include(code)
 except (TemplateError, ImportError, InvalidIncludePath):
  pass
 messages = []
 messages += [(m.start(), m.groups()[0]) for m in re.compile(u'_\\("([^"]*)"').finditer(code)]
 messages += [(m.start(), m.groups()[0]) for m in re.compile(u"_\\('([^']*)'").finditer(code)]
 if is_py:
  messages += [(m.start(), m.groups()[0]) for m in re.compile(u'_\\("{3}([^"]*)"{3}.*\\)').finditer(code)]
 messages = [(pos, message) for (pos, message) in messages if is_translatable(message)]
 return pos_to_line_no(messages, code)

def extract_messages_from_code ( code , is_py = False ) : try : code = render_include ( code ) except ( TemplateError , ImportError , InvalidIncludePath ) : pass messages = [ ] messages += [ ( m . start ( ) , m . groups ( ) [ 0 ] ) for m in re . compile ( u'_\\("([^"]*)"' ) . finditer ( code ) ] messages += [ ( m . start ( ) , m . groups ( ) [ 0 ] ) for m in re . compile ( u"_\\('([^']*)'" ) . finditer ( code ) ] if is_py : messages += [ ( m . start ( ) , m . groups ( ) [ 0 ] ) for m in re . compile ( u'_\\("{3}([^"]*)"{3}.*\\)' ) . finditer ( code ) ] messages = [ ( pos , message ) for ( pos , message ) in messages if is_translatable ( message ) ] return pos_to_line_no ( messages , code )
extracts translatable srings from a code file .