Index: trunk/extensions/Translate/MessageChecks.php |
— | — | @@ -358,4 +358,34 @@ |
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
| 362 | + protected function balancedTagsCheck( $messages, $code, &$warnings ) { |
| 363 | + foreach ( $messages as $message ) { |
| 364 | + $key = $message->key(); |
| 365 | + $translation = $message->translation(); |
| 366 | + |
| 367 | + libxml_use_internal_errors( true ); |
| 368 | + libxml_clear_errors(); |
| 369 | + $doc = simplexml_load_string( Xml::tags( 'root', null, $translation )); |
| 370 | + if ($doc) continue; |
| 371 | + |
| 372 | + $errors = libxml_get_errors(); |
| 373 | + $params = array(); |
| 374 | + foreach ( $errors as $error ) { |
| 375 | + if ( $error->code !== 76 && $error->code !== 73 ) continue; |
| 376 | + $params[] = "<br />• [{$error->code}] $error->message"; |
| 377 | + } |
| 378 | + |
| 379 | + if ( !count( $params ) ) continue; |
| 380 | + |
| 381 | + $warnings[$key][] = array( |
| 382 | + array( 'tags', 'balance', $key, $code ), |
| 383 | + 'translate-checks-format', |
| 384 | + array( 'PARAMS', $params ), |
| 385 | + array( 'COUNT', count( $params ) ), |
| 386 | + ); |
| 387 | + } |
| 388 | + |
| 389 | + libxml_clear_errors(); |
| 390 | + } |
| 391 | + |
362 | 392 | } |