http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73291
Revision: 73291
Author: nikerabbit
Date: 2010-09-18 14:20:56 +0000 (Sat, 18 Sep 2010)
Log Message:
-----------
Add checker for balanced html
Modified Paths:
--------------
trunk/extensions/Translate/MessageChecks.php
Modified: trunk/extensions/Translate/MessageChecks.php
===================================================================
--- trunk/extensions/Translate/MessageChecks.php 2010-09-18 14:05:48 UTC
(rev 73290)
+++ trunk/extensions/Translate/MessageChecks.php 2010-09-18 14:20:56 UTC
(rev 73291)
@@ -358,4 +358,34 @@
}
}
+ protected function balancedTagsCheck( $messages, $code, &$warnings ) {
+ foreach ( $messages as $message ) {
+ $key = $message->key();
+ $translation = $message->translation();
+
+ libxml_use_internal_errors( true );
+ libxml_clear_errors();
+ $doc = simplexml_load_string( Xml::tags( 'root', null,
$translation ));
+ if ($doc) continue;
+
+ $errors = libxml_get_errors();
+ $params = array();
+ foreach ( $errors as $error ) {
+ if ( $error->code !== 76 && $error->code !== 73
) continue;
+ $params[] = "<br />• [{$error->code}]
$error->message";
+ }
+
+ if ( !count( $params ) ) continue;
+
+ $warnings[$key][] = array(
+ array( 'tags', 'balance', $key, $code ),
+ 'translate-checks-format',
+ array( 'PARAMS', $params ),
+ array( 'COUNT', count( $params ) ),
+ );
+ }
+
+ libxml_clear_errors();
+ }
+
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs