parameters: (item, lang)
return_statement: return '\n    case %s:\n      return "%s";' % (name_attr, message)
docstring: Format a single <message> element.
docstring_summary: Format a single <message> element.
docstring_tokens: Format a single <message > element .
function: def _FormatMessage(item, lang):
    """Format a single <message> element."""
  
    message = item.ws_at_start + item.Translate(lang) + item.ws_at_end
    # output message with non-ascii chars escaped as octal numbers
    # C's grammar allows escaped hexadecimal numbers to be infinite,
    # but octal is always of the form \OOO
    message = message.encode('utf-8').encode('string_escape')
    # an escaped char is (\xHH)+ but only if the initial
    # backslash is not escaped.
    not_a_backslash = r"(^|[^\\])"  # beginning of line or a non-backslash char
    escaped_backslashes = not_a_backslash + r"(\\\\)*"
    hex_digits = r"((\\x)[0-9a-f]{2})+"
    two_digit_hex_num = re.compile(
      r"(?P<escaped_backslashes>%s)(?P<hex>%s)"
      % (escaped_backslashes, hex_digits))
    message = two_digit_hex_num.sub(_HexToOct, message)
    # unescape \ (convert \\ back to \)
    message = message.replace('\\\\', '\\')
    message = message.replace('"', '\\"')
    message = util.LINEBREAKS.sub(r'\\n', message)
  
    name_attr = item.GetTextualIds()[0]
  
    return '\n    case %s:\n      return "%s";' % (name_attr, message)
function_tokens: def _FormatMessage ( item , lang ) : message = item . ws_at_start + item . Translate ( lang ) + item . ws_at_end # output message with non-ascii chars escaped as octal numbers # C's grammar allows escaped hexadecimal numbers to be infinite, # but octal is always of the form \OOO message = message . encode ( 'utf-8' ) . encode ( 'string_escape' ) # an escaped char is (\xHH)+ but only if the initial # backslash is not escaped. not_a_backslash = r"(^|[^\\])" # beginning of line or a non-backslash char escaped_backslashes = not_a_backslash + r"(\\\\)*" hex_digits = r"((\\x)[0-9a-f]{2})+" two_digit_hex_num = re . compile ( r"(?P<escaped_backslashes>%s)(?P<hex>%s)" % ( escaped_backslashes , hex_digits ) ) message = two_digit_hex_num . sub ( _HexToOct , message ) # unescape \ (convert \\ back to \) message = message . replace ( '\\\\' , '\\' ) message = message . replace ( '"' , '\\"' ) message = util . LINEBREAKS . sub ( r'\\n' , message ) name_attr = item . GetTextualIds ( ) [ 0 ] return '\n    case %s:\n      return "%s";' % ( name_attr , message )