/* localize.c -- text strings and routines to handle errors and general messages (c) 1998-2008 (W3C) MIT, ERCIM, Keio University Portions Copyright University of Toronto See tidy.h and access.h for the copyright notice. You should only need to edit this file and tidy.c to localize HTML tidy. *** This needs checking *** CVS Info : $Author: arnaud02 $ $Date: 2008/06/18 20:18:54 $ $Revision: 1.178 $ */ #include "tidy-int.h" #include "lexer.h" #include "streamio.h" #include "message.h" #include "tmbstr.h" #include "utf8.h" /* used to point to Web Accessibility Guidelines */ #define ACCESS_URL "http://www.w3.org/WAI/GL" /* points to the Adaptive Technology Resource Centre at the ** University of Toronto */ #define ATRC_ACCESS_URL "http://www.aprompt.ca/Tidy/accessibilitychecks.html" #include "version.h" ctmbstr TY_(ReleaseDate)(void) { return TY_(release_date); } static struct _msgfmt { uint code; ctmbstr fmt; } const msgFormat[] = { /* ReportEncodingWarning */ { ENCODING_MISMATCH, "specified input encoding (%s) does not match actual input encoding (%s)" }, /* Warning */ /* ReportEncodingError */ { VENDOR_SPECIFIC_CHARS, "%s invalid character code %s" }, /* Error */ { INVALID_SGML_CHARS, "%s invalid character code %s" }, /* Error */ { INVALID_UTF8, "%s invalid UTF-8 bytes (char. code %s)" }, /* Error */ { INVALID_UTF16, "%s invalid UTF-16 surrogate pair (char. code %s)" }, /* Error */ { INVALID_NCR, "%s invalid numeric character reference %s" }, /* Error */ /* ReportEntityError */ { MISSING_SEMICOLON, "entity \"%s\" doesn't end in ';'" }, /* Warning in HTML, Error in XML/XHTML */ { MISSING_SEMICOLON_NCR, "numeric character reference \"%s\" doesn't end in ';'" }, /* Warning in HTML, Error in XML/XHTML */ { UNESCAPED_AMPERSAND, "unescaped & which should be written as &" }, /* Warning in HTML, Error in XHTML */ { UNKNOWN_ENTITY, "unescaped & or unknown entity \"%s\"" }, /* Error */ { APOS_UNDEFINED, "named entity ' only defined in XML/XHTML" }, /* Error in HTML (should only occur for HTML input) */ /* ReportAttrError */ /* attribute name */ { INSERTING_ATTRIBUTE, "%s inserting \"%s\" attribute" }, /* Warning in CheckLINK, Error otherwise */ { MISSING_ATTR_VALUE, "%s attribute \"%s\" lacks value" }, /* Warning in CheckUrl, Error otherwise */ { UNKNOWN_ATTRIBUTE, "%s unknown attribute \"%s\"" }, /* Error */ { PROPRIETARY_ATTRIBUTE, "%s proprietary attribute \"%s\"" }, /* Error */ { JOINING_ATTRIBUTE, "%s joining values of repeated attribute \"%s\"" }, /* Error */ { XML_ATTRIBUTE_VALUE, "%s has XML attribute \"%s\"" }, /* Error (but deprecated) */ /* attribute value */ { XML_ID_SYNTAX, "%s ID \"%s\" uses XML ID syntax" }, /* Warning if XHTML, Error if HTML */ { ATTR_VALUE_NOT_LCASE, "%s attribute value \"%s\" must be lower case for XHTML" }, /* Error if XHTML input, Notice if HTML input and XHTML outout */ { PROPRIETARY_ATTR_VALUE, "%s proprietary attribute value \"%s\"" }, /* Error */ { ANCHOR_NOT_UNIQUE, "%s anchor \"%s\" already defined" }, /* Error */ /* attribute name, attribute value */ { BAD_ATTRIBUTE_VALUE, "%s attribute \"%s\" has invalid value \"%s\"" }, /* Error */ { BAD_ATTRIBUTE_VALUE_REPLACED, "%s attribute \"%s\" had invalid value \"%s\" and has been replaced" }, /* Error */ { INVALID_ATTRIBUTE, "%s attribute name \"%s\" (value=\"%s\") is invalid" }, /* Error */ /* attribute value, attribute name */ { REPEATED_ATTRIBUTE, "%s dropping value \"%s\" for repeated attribute \"%s\"" }, /* Error */ /* no arguments */ { INVALID_XML_ID, "%s cannot copy name attribute to id" }, /* Warning */ { UNEXPECTED_GT, "%s missing '>' for end of tag" }, /* Warning if HTML, Error if XML/XHTML */ { UNEXPECTED_QUOTEMARK, "%s unexpected or duplicate quote mark" }, /* Error */ { MISSING_QUOTEMARK, "%s attribute with missing trailing quote mark" }, /* Error */ { UNEXPECTED_END_OF_FILE_ATTR, "%s end of file while parsing attributes" }, /* Error */ { ID_NAME_MISMATCH, "%s id and name attribute value mismatch" }, /* Error */ { BACKSLASH_IN_URI, "%s URI reference contains backslash. Typo?" }, /* Error */ { FIXED_BACKSLASH, "%s converting backslash in URI to slash" }, /* Error */ { ILLEGAL_URI_REFERENCE, "%s improperly escaped URI reference" }, /* Error */ { ESCAPED_ILLEGAL_URI, "%s escaping malformed URI reference" }, /* Error */ { NEWLINE_IN_URI, "%s discarding newline in URI reference" }, /* Error */ { WHITE_IN_URI, "%s discarding whitespace in URI reference" }, /* Error */ { UNEXPECTED_EQUALSIGN, "%s unexpected '=', expected attribute name" }, /* Error */ { MISSING_IMAGEMAP, "%s should use client-side image map" }, /* Warning (but deprecated) */ /* ReportMissingAttr */ { MISSING_ATTRIBUTE, "%s lacks \"%s\" attribute" }, /* Error */ /* ReportWarning */ { NESTED_EMPHASIS, "nested emphasis %s" }, /* Warning */ { NESTED_QUOTATION, "nested q elements, possible typo." }, /* Warning */ { OBSOLETE_ELEMENT, "replacing obsolete element %s by %s" }, /* Warning */ { COERCE_TO_ENDTAG_WARN, "<%s> is probably intended as " }, /* Warning */ /* ReportNotice */ { TRIM_EMPTY_ELEMENT, "trimming empty %s" }, /* Notice */ { REPLACING_ELEMENT, "replacing %s by %s" }, /* Notice */ /* ReportError */ { COERCE_TO_ENDTAG, "<%s> is probably intended as " }, /* Error */ { REPLACING_UNEX_ELEMENT, "replacing unexpected %s by %s" }, /* Error */ { MISSING_ENDTAG_FOR, "missing " }, /* Error */ { MISSING_ENDTAG_BEFORE, "missing before %s" }, /* Error */ { DISCARDING_UNEXPECTED, "discarding unexpected %s" }, /* Error */ { NON_MATCHING_ENDTAG, "replacing unexpected %s by " }, /* Error */ { TAG_NOT_ALLOWED_IN, "%s isn't allowed in <%s> elements" }, /* Error */ { MISSING_STARTTAG, "missing <%s>" }, /* Error */ { UNEXPECTED_ENDTAG, "unexpected " }, /* Error */ { TOO_MANY_ELEMENTS, "too many %s elements" }, /* Error */ { USING_BR_INPLACE_OF, "using
in place of %s" }, /* Error */ { INSERTING_TAG, "inserting implicit <%s>" }, /* Error */ { CANT_BE_NESTED, "%s can't be nested" }, /* Error */ { PROPRIETARY_ELEMENT, "%s is not approved by W3C" }, /* Error */ { ILLEGAL_NESTING, "%s shouldn't be nested" }, /* Error */ { NOFRAMES_CONTENT, "%s not inside 'noframes' element" }, /* Error */ { UNEXPECTED_END_OF_FILE, "unexpected end of file %s" }, /* Error */ { ELEMENT_NOT_EMPTY, "%s element not empty or not closed" }, /* Error */ { UNEXPECTED_ENDTAG_IN, "unexpected in <%s>" }, /* Error */ { TOO_MANY_ELEMENTS_IN, "too many %s elements in <%s>" }, /* Error */ { UNESCAPED_ELEMENT, "unescaped %s in pre content" }, /* Error (but deprecated) */ /* no arguments */ { DOCTYPE_AFTER_TAGS, " isn't allowed after elements" }, /* Error */ { MISSING_TITLE_ELEMENT, "inserting missing 'title' element" }, /* Error */ { INCONSISTENT_VERSION, "HTML DOCTYPE doesn't match content" }, /* Error */ { MISSING_DOCTYPE, "missing declaration" }, /* Error */ { CONTENT_AFTER_BODY, "content occurs after end of body" }, /* Error */ { MALFORMED_COMMENT, "adjacent hyphens within comment" }, /* Error */ { BAD_COMMENT_CHARS, "expecting -- or >" }, /* Error */ { BAD_CDATA_CONTENT, "'<' + '/' + letter not allowed here" }, /* Error */ { INCONSISTENT_NAMESPACE, "HTML namespace doesn't match content" }, /* Error */ { SPACE_PRECEDING_XMLDECL, "removing whitespace preceding XML Declaration" }, /* Error */ { MALFORMED_DOCTYPE, "discarding malformed " }, /* Error */ { BAD_XML_COMMENT, "XML comments can't contain --" }, /* Error (but deprecated) */ { DTYPE_NOT_UPPER_CASE, "SYSTEM, PUBLIC, W3C, DTD, EN must be upper case" }, /* Error (but deprecated) */ { ENCODING_IO_CONFLICT, "Output encoding does not work with standard output" }, /* Error (but deprecated) */ /* ReportFatal */ { SUSPECTED_MISSING_QUOTE, "missing quote mark for attribute value" }, /* Error? (not really sometimes) */ { DUPLICATE_FRAMESET, "repeated FRAMESET element" }, /* Error */ { UNKNOWN_ELEMENT, "%s is not recognized!" }, /* Error */ { UNEXPECTED_ENDTAG, "unexpected " }, /* Error */ /* */ { PREVIOUS_LOCATION, "<%s> previously mentioned" }, /* Info */ #if SUPPORT_ACCESSIBILITY_CHECKS /* ReportAccess */ /* List of error/warning messages. The error code corresponds to the check that is listed in the AERT (HTML specifications). */ { IMG_MISSING_ALT, "[1.1.1.1]: missing 'alt' text." }, /* Access */ { IMG_ALT_SUSPICIOUS_FILENAME, "[1.1.1.2]: suspicious 'alt' text (filename)." }, /* Access */ { IMG_ALT_SUSPICIOUS_FILE_SIZE, "[1.1.1.3]: suspicious 'alt' text (file size)." }, /* Access */ { IMG_ALT_SUSPICIOUS_PLACEHOLDER, "[1.1.1.4]: suspicious 'alt' text (placeholder)." }, /* Access */ { IMG_ALT_SUSPICIOUS_TOO_LONG, "[1.1.1.10]: suspicious 'alt' text (too long)." }, /* Access */ { IMG_MISSING_LONGDESC_DLINK, "[1.1.2.1]: missing 'longdesc' and d-link." }, /* Access */ { IMG_MISSING_DLINK, "[1.1.2.2]: missing d-link." }, /* Access */ { IMG_MISSING_LONGDESC, "[1.1.2.3]: missing 'longdesc'." }, /* Access */ { IMG_BUTTON_MISSING_ALT, "[1.1.3.1]: (button) missing 'alt' text." }, /* Access */ { APPLET_MISSING_ALT, "[1.1.4.1]: missing alternate content." }, /* Access */ { OBJECT_MISSING_ALT, "[1.1.5.1]: missing alternate content." }, /* Access */ { AUDIO_MISSING_TEXT_WAV, "[1.1.6.1]: audio missing text transcript (wav)." }, /* Access */ { AUDIO_MISSING_TEXT_AU, "[1.1.6.2]: audio missing text transcript (au)." }, /* Access */ { AUDIO_MISSING_TEXT_AIFF, "[1.1.6.3]: audio missing text transcript (aiff)." }, /* Access */ { AUDIO_MISSING_TEXT_SND, "[1.1.6.4]: audio missing text transcript (snd)." }, /* Access */ { AUDIO_MISSING_TEXT_RA, "[1.1.6.5]: audio missing text transcript (ra)." }, /* Access */ { AUDIO_MISSING_TEXT_RM, "[1.1.6.6]: audio missing text transcript (rm)." }, /* Access */ { FRAME_MISSING_LONGDESC, "[1.1.8.1]: may require 'longdesc'." }, /* Access */ { AREA_MISSING_ALT, "[1.1.9.1]: missing 'alt' text." }, /* Access */ { SCRIPT_MISSING_NOSCRIPT, "[1.1.10.1]: