def html_translate(callback, value):
 if (not value):
  return value
 try:
  parser = etree.HTMLParser(encoding='utf-8')
  trans = XMLTranslator(callback, 'html', parser)
  wrapped = ('<div>%s</div>' % encode(value))
  root = etree.fromstring(wrapped, parser)
  trans.process(root[0][0])
  value = trans.get_done()[5:(-6)]
 except ValueError:
  _logger.exception('Cannot translate malformed HTML, using source value instead')
 return value

def html_translate ( callback , value ) : if ( not value ) : return value try : parser = etree . HTMLParser ( encoding = 'utf-8' ) trans = XMLTranslator ( callback , 'html' , parser ) wrapped = ( '<div>%s</div>' % encode ( value ) ) root = etree . fromstring ( wrapped , parser ) trans . process ( root [ 0 ] [ 0 ] ) value = trans . get_done ( ) [ 5 : ( - 6 ) ] except ValueError : _logger . exception ( 'Cannot translate malformed HTML, using source value instead' ) return value
translate an html value .