def parse_language(speaker, emote):
 emote = _RE_REF_LANG.sub('\\1', emote)
 errors = []
 mapping = {}
 for (imatch, say_match) in enumerate(reversed(list(_RE_LANGUAGE.finditer(emote)))):
  (langname, saytext) = say_match.groups()
  (istart, iend) = (say_match.start(), say_match.end())
  key = ('##%i' % imatch)
  emote = ((emote[:istart] + ('{%s}' % key)) + emote[iend:])
  mapping[key] = (langname, saytext)
 if errors:
  raise LanguageError('\n'.join(errors))
 return (emote, mapping)

def parse_language ( speaker , emote ) : emote = _RE_REF_LANG . sub ( '\\1' , emote ) errors = [ ] mapping = { } for ( imatch , say_match ) in enumerate ( reversed ( list ( _RE_LANGUAGE . finditer ( emote ) ) ) ) : ( langname , saytext ) = say_match . groups ( ) ( istart , iend ) = ( say_match . start ( ) , say_match . end ( ) ) key = ( '##%i' % imatch ) emote = ( ( emote [ : istart ] + ( '{%s}' % key ) ) + emote [ iend : ] ) mapping [ key ] = ( langname , saytext ) if errors : raise LanguageError ( '\n' . join ( errors ) ) return ( emote , mapping )
parse the emote for language .