Merge "Adding a quotation marks message to core."
[lhc/web/wiklou.git] / maintenance / language / checkLanguage.inc
1 <?php
2 /**
3 * Helper class for checkLanguage.php script.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup MaintenanceLanguage
22 */
23
24 /**
25 * @ingroup MaintenanceLanguage
26 */
27 class CheckLanguageCLI {
28 protected $code = null;
29 protected $level = 2;
30 protected $doLinks = false;
31 protected $linksPrefix = '';
32 protected $wikiCode = 'en';
33 protected $checkAll = false;
34 protected $output = 'plain';
35 protected $checks = array();
36 protected $L = null;
37
38 protected $results = array();
39
40 private $includeExif = false;
41
42 /**
43 * Constructor.
44 * @param $options array Options for script.
45 */
46 public function __construct( array $options ) {
47 if ( isset( $options['help'] ) ) {
48 echo $this->help();
49 exit( 1 );
50 }
51
52 if ( isset( $options['lang'] ) ) {
53 $this->code = $options['lang'];
54 } else {
55 global $wgLanguageCode;
56 $this->code = $wgLanguageCode;
57 }
58
59 if ( isset( $options['level'] ) ) {
60 $this->level = $options['level'];
61 }
62
63 $this->doLinks = isset( $options['links'] );
64 $this->includeExif = !isset( $options['noexif'] );
65 $this->checkAll = isset( $options['all'] );
66
67 if ( isset( $options['prefix'] ) ) {
68 $this->linksPrefix = $options['prefix'];
69 }
70
71 if ( isset( $options['wikilang'] ) ) {
72 $this->wikiCode = $options['wikilang'];
73 }
74
75 if ( isset( $options['whitelist'] ) ) {
76 $this->checks = explode( ',', $options['whitelist'] );
77 } elseif ( isset( $options['blacklist'] ) ) {
78 $this->checks = array_diff(
79 isset( $options['easy'] ) ? $this->easyChecks() : $this->defaultChecks(),
80 explode( ',', $options['blacklist'] )
81 );
82 } elseif ( isset( $options['easy'] ) ) {
83 $this->checks = $this->easyChecks();
84 } else {
85 $this->checks = $this->defaultChecks();
86 }
87
88 if ( isset( $options['output'] ) ) {
89 $this->output = $options['output'];
90 }
91
92 $this->L = new languages( $this->includeExif );
93 }
94
95 /**
96 * Get the default checks.
97 * @return array A list of the default checks.
98 */
99 protected function defaultChecks() {
100 return array(
101 'untranslated', 'duplicate', 'obsolete', 'variables', 'empty', 'plural',
102 'whitespace', 'xhtml', 'chars', 'links', 'unbalanced', 'namespace',
103 'projecttalk', 'magic', 'magic-old', 'magic-over', 'magic-case',
104 'special', 'special-old',
105 );
106 }
107
108 /**
109 * Get the checks which check other things than messages.
110 * @return array A list of the non-message checks.
111 */
112 protected function nonMessageChecks() {
113 return array(
114 'namespace', 'projecttalk', 'magic', 'magic-old', 'magic-over',
115 'magic-case', 'special', 'special-old',
116 );
117 }
118
119 /**
120 * Get the checks that can easily be treated by non-speakers of the language.
121 * @return Array A list of the easy checks.
122 */
123 protected function easyChecks() {
124 return array(
125 'duplicate', 'obsolete', 'empty', 'whitespace', 'xhtml', 'chars', 'magic-old',
126 'magic-over', 'magic-case', 'special-old',
127 );
128 }
129
130 /**
131 * Get all checks.
132 * @return array An array of all check names mapped to their function names.
133 */
134 protected function getChecks() {
135 return array(
136 'untranslated' => 'getUntranslatedMessages',
137 'duplicate' => 'getDuplicateMessages',
138 'obsolete' => 'getObsoleteMessages',
139 'variables' => 'getMessagesWithMismatchVariables',
140 'plural' => 'getMessagesWithoutPlural',
141 'empty' => 'getEmptyMessages',
142 'whitespace' => 'getMessagesWithWhitespace',
143 'xhtml' => 'getNonXHTMLMessages',
144 'chars' => 'getMessagesWithWrongChars',
145 'links' => 'getMessagesWithDubiousLinks',
146 'unbalanced' => 'getMessagesWithUnbalanced',
147 'namespace' => 'getUntranslatedNamespaces',
148 'projecttalk' => 'getProblematicProjectTalks',
149 'magic' => 'getUntranslatedMagicWords',
150 'magic-old' => 'getObsoleteMagicWords',
151 'magic-over' => 'getOverridingMagicWords',
152 'magic-case' => 'getCaseMismatchMagicWords',
153 'special' => 'getUntraslatedSpecialPages',
154 'special-old' => 'getObsoleteSpecialPages',
155 );
156 }
157
158 /**
159 * Get total count for each check non-messages check.
160 * @return array An array of all check names mapped to a two-element array:
161 * function name to get the total count and language code or null
162 * for checked code.
163 */
164 protected function getTotalCount() {
165 return array(
166 'namespace' => array( 'getNamespaceNames', 'en' ),
167 'projecttalk' => null,
168 'magic' => array( 'getMagicWords', 'en' ),
169 'magic-old' => array( 'getMagicWords', null ),
170 'magic-over' => array( 'getMagicWords', null ),
171 'magic-case' => array( 'getMagicWords', null ),
172 'special' => array( 'getSpecialPageAliases', 'en' ),
173 'special-old' => array( 'getSpecialPageAliases', null ),
174 );
175 }
176
177 /**
178 * Get all check descriptions.
179 * @return array An array of all check names mapped to their descriptions.
180 */
181 protected function getDescriptions() {
182 return array(
183 'untranslated' => '$1 message(s) of $2 are not translated to $3, but exist in en:',
184 'duplicate' => '$1 message(s) of $2 are translated the same in en and $3:',
185 'obsolete' => '$1 message(s) of $2 do not exist in en or are in the ignore list, but exist in $3:',
186 'variables' => '$1 message(s) of $2 in $3 don\'t match the variables used in en:',
187 'plural' => '$1 message(s) of $2 in $3 don\'t use {{plural}} while en uses:',
188 'empty' => '$1 message(s) of $2 in $3 are empty or -:',
189 'whitespace' => '$1 message(s) of $2 in $3 have trailing whitespace:',
190 'xhtml' => '$1 message(s) of $2 in $3 contain illegal XHTML:',
191 'chars' => '$1 message(s) of $2 in $3 include hidden chars which should not be used in the messages:',
192 'links' => '$1 message(s) of $2 in $3 have problematic link(s):',
193 'unbalanced' => '$1 message(s) of $2 in $3 have unbalanced {[]}:',
194 'namespace' => '$1 namespace name(s) of $2 are not translated to $3, but exist in en:',
195 'projecttalk' => '$1 namespace name(s) and alias(es) in $3 are project talk namespaces without the parameter:',
196 'magic' => '$1 magic word(s) of $2 are not translated to $3, but exist in en:',
197 'magic-old' => '$1 magic word(s) of $2 do not exist in en, but exist in $3:',
198 'magic-over' => '$1 magic word(s) of $2 in $3 do not contain the original en word(s):',
199 'magic-case' => '$1 magic word(s) of $2 in $3 change the case-sensitivity of the original en word:',
200 'special' => '$1 special page alias(es) of $2 are not translated to $3, but exist in en:',
201 'special-old' => '$1 special page alias(es) of $2 do not exist in en, but exist in $3:',
202 );
203 }
204
205 /**
206 * Get help.
207 * @return string The help string.
208 */
209 protected function help() {
210 return <<<ENDS
211 Run this script to check a specific language file, or all of them.
212 Command line settings are in form --parameter[=value].
213 Parameters:
214 --help: Show this help.
215 --lang: Language code (default: the installation default language).
216 --all: Check all customized languages.
217 --level: Show the following display level (default: 2):
218 * 0: Skip the checks (useful for checking syntax).
219 * 1: Show only the stub headers and number of wrong messages, without list of messages.
220 * 2: Show only the headers and the message keys, without the message values.
221 * 3: Show both the headers and the complete messages, with both keys and values.
222 --links: Link the message values (default off).
223 --prefix: prefix to add to links.
224 --wikilang: For the links, what is the content language of the wiki to display the output in (default en).
225 --noexif: Do not check for Exif messages (a bit hard and boring to translate), if you know
226 that they are currently not translated and want to focus on other problems (default off).
227 --whitelist: Do only the following checks (form: code,code).
228 --blacklist: Do not do the following checks (form: code,code).
229 --easy: Do only the easy checks, which can be treated by non-speakers of the language.
230
231 Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
232 * untranslated: Messages which are required to translate, but are not translated.
233 * duplicate: Messages which translation equal to fallback
234 * obsolete: Messages which are untranslatable or do not exist, but are translated.
235 * variables: Messages without variables which should be used, or with variables which should not be used.
236 * empty: Empty messages and messages that contain only -.
237 * whitespace: Messages which have trailing whitespace.
238 * xhtml: Messages which are not well-formed XHTML (checks only few common errors).
239 * chars: Messages with hidden characters.
240 * links: Messages which contains broken links to pages (does not find all).
241 * unbalanced: Messages which contains unequal numbers of opening {[ and closing ]}.
242 * namespace: Namespace names that were not translated.
243 * projecttalk: Namespace names and aliases where the project talk does not contain $1.
244 * magic: Magic words that were not translated.
245 * magic-old: Magic words which do not exist.
246 * magic-over: Magic words that override the original English word.
247 * magic-case: Magic words whose translation changes the case-sensitivity of the original English word.
248 * special: Special page names that were not translated.
249 * special-old: Special page names which do not exist.
250
251 ENDS;
252 }
253
254 /**
255 * Execute the script.
256 */
257 public function execute() {
258 $this->doChecks();
259 if ( $this->level > 0 ) {
260 switch ( $this->output ) {
261 case 'plain':
262 $this->outputText();
263 break;
264 case 'wiki':
265 $this->outputWiki();
266 break;
267 default:
268 throw new MWException( "Invalid output type $this->output" );
269 }
270 }
271 }
272
273 /**
274 * Execute the checks.
275 */
276 protected function doChecks() {
277 $ignoredCodes = array( 'en', 'enRTL' );
278
279 $this->results = array();
280 # Check the language
281 if ( $this->checkAll ) {
282 foreach ( $this->L->getLanguages() as $language ) {
283 if ( !in_array( $language, $ignoredCodes ) ) {
284 $this->results[$language] = $this->checkLanguage( $language );
285 }
286 }
287 } else {
288 if ( in_array( $this->code, $ignoredCodes ) ) {
289 throw new MWException( "Cannot check code $this->code." );
290 } else {
291 $this->results[$this->code] = $this->checkLanguage( $this->code );
292 }
293 }
294
295 $results = $this->results;
296 foreach ( $results as $code => $checks ) {
297 foreach ( $checks as $check => $messages ) {
298 foreach ( $messages as $key => $details ) {
299 if ( $this->isCheckBlacklisted( $check, $code, $key ) ) {
300 unset( $this->results[$code][$check][$key] );
301 }
302 }
303 }
304 }
305 }
306
307 /**
308 * Get the check blacklist.
309 * @return array The list of checks which should not be executed.
310 */
311 protected function getCheckBlacklist() {
312 static $blacklist = null;
313
314 if ( $blacklist !== null ) {
315 return $blacklist;
316 }
317
318 global $checkBlacklist;
319
320 $blacklist = $checkBlacklist;
321
322 wfRunHooks( 'LocalisationChecksBlacklist', array( &$blacklist ) );
323
324 return $blacklist;
325 }
326
327 /**
328 * Verify whether a check is blacklisted.
329 *
330 * @param string $check Check name
331 * @param string $code Language code
332 * @param string|bool $message Message name, or False for a whole language
333 * @return bool Whether the check is blacklisted
334 */
335 protected function isCheckBlacklisted( $check, $code, $message ) {
336 $blacklist = $this->getCheckBlacklist();
337
338 foreach ( $blacklist as $item ) {
339 if ( isset( $item['check'] ) && $check !== $item['check'] ) {
340 continue;
341 }
342
343 if ( isset( $item['code'] ) && !in_array( $code, $item['code'] ) ) {
344 continue;
345 }
346
347 if ( isset( $item['message'] ) &&
348 ( $message === false || !in_array( $message, $item['message'] ) )
349 ) {
350 continue;
351 }
352
353 return true;
354 }
355
356 return false;
357 }
358
359 /**
360 * Check a language.
361 * @param $code string The language code.
362 * @throws MWException
363 * @return array The results.
364 */
365 protected function checkLanguage( $code ) {
366 # Syntax check only
367 $results = array();
368 if ( $this->level === 0 ) {
369 $this->L->getMessages( $code );
370
371 return $results;
372 }
373
374 $checkFunctions = $this->getChecks();
375 foreach ( $this->checks as $check ) {
376 if ( $this->isCheckBlacklisted( $check, $code, false ) ) {
377 $results[$check] = array();
378 continue;
379 }
380
381 $callback = array( $this->L, $checkFunctions[$check] );
382 if ( !is_callable( $callback ) ) {
383 throw new MWException( "Unkown check $check." );
384 }
385 $results[$check] = call_user_func( $callback, $code );
386 }
387
388 return $results;
389 }
390
391 /**
392 * Format a message key.
393 * @param $key string The message key.
394 * @param $code string The language code.
395 * @return string The formatted message key.
396 */
397 protected function formatKey( $key, $code ) {
398 if ( $this->doLinks ) {
399 $displayKey = ucfirst( $key );
400 if ( $code == $this->wikiCode ) {
401 return "[[{$this->linksPrefix}MediaWiki:$displayKey|$key]]";
402 } else {
403 return "[[{$this->linksPrefix}MediaWiki:$displayKey/$code|$key]]";
404 }
405 } else {
406 return $key;
407 }
408 }
409
410 /**
411 * Output the checks results as plain text.
412 */
413 protected function outputText() {
414 foreach ( $this->results as $code => $results ) {
415 $translated = $this->L->getMessages( $code );
416 $translated = count( $translated['translated'] );
417 foreach ( $results as $check => $messages ) {
418 $count = count( $messages );
419 if ( $count ) {
420 if ( $check == 'untranslated' ) {
421 $translatable = $this->L->getGeneralMessages();
422 $total = count( $translatable['translatable'] );
423 } elseif ( in_array( $check, $this->nonMessageChecks() ) ) {
424 $totalCount = $this->getTotalCount();
425 $totalCount = $totalCount[$check];
426 $callback = array( $this->L, $totalCount[0] );
427 $callCode = $totalCount[1] ? $totalCount[1] : $code;
428 $total = count( call_user_func( $callback, $callCode ) );
429 } else {
430 $total = $translated;
431 }
432 $search = array( '$1', '$2', '$3' );
433 $replace = array( $count, $total, $code );
434 $descriptions = $this->getDescriptions();
435 echo "\n" . str_replace( $search, $replace, $descriptions[$check] ) . "\n";
436 if ( $this->level == 1 ) {
437 echo "[messages are hidden]\n";
438 } else {
439 foreach ( $messages as $key => $value ) {
440 if ( !in_array( $check, $this->nonMessageChecks() ) ) {
441 $key = $this->formatKey( $key, $code );
442 }
443 if ( $this->level == 2 || empty( $value ) ) {
444 echo "* $key\n";
445 } else {
446 echo "* $key: '$value'\n";
447 }
448 }
449 }
450 }
451 }
452 }
453 }
454
455 /**
456 * Output the checks results as wiki text.
457 */
458 function outputWiki() {
459 $detailText = '';
460 $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
461 foreach ( $this->results as $code => $results ) {
462 $detailTextForLang = "==$code==\n";
463 $numbers = array();
464 $problems = 0;
465 $detailTextForLangChecks = array();
466 foreach ( $results as $check => $messages ) {
467 if ( in_array( $check, $this->nonMessageChecks() ) ) {
468 continue;
469 }
470 $count = count( $messages );
471 if ( $count ) {
472 $problems += $count;
473 $messageDetails = array();
474 foreach ( $messages as $key => $details ) {
475 $displayKey = $this->formatKey( $key, $code );
476 $messageDetails[] = $displayKey;
477 }
478 $detailTextForLangChecks[] = "=== $code-$check ===\n* " . implode( ', ', $messageDetails );
479 $numbers[] = "'''[[#$code-$check|$count]]'''";
480 } else {
481 $numbers[] = $count;
482 }
483 }
484
485 if ( count( $detailTextForLangChecks ) ) {
486 $detailText .= $detailTextForLang . implode( "\n", $detailTextForLangChecks ) . "\n";
487 }
488
489 if ( !$problems ) {
490 # Don't list languages without problems
491 continue;
492 }
493 $language = Language::fetchLanguageName( $code );
494 $rows[] = "| $language || $code || $problems || " . implode( ' || ', $numbers );
495 }
496
497 $tableRows = implode( "\n|-\n", $rows );
498
499 $version = SpecialVersion::getVersion( 'nodb' );
500 echo <<<EOL
501 '''Check results are for:''' <code>$version</code>
502
503
504 {| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear: both;"
505 $tableRows
506 |}
507
508 $detailText
509
510 EOL;
511 }
512
513 /**
514 * Check if there are any results for the checks, in any language.
515 * @return bool True if there are any results, false if not.
516 */
517 protected function isEmpty() {
518 foreach ( $this->results as $results ) {
519 foreach ( $results as $messages ) {
520 if ( !empty( $messages ) ) {
521 return false;
522 }
523 }
524 }
525
526 return true;
527 }
528 }
529
530 /**
531 * @ingroup MaintenanceLanguage
532 */
533 class CheckExtensionsCLI extends CheckLanguageCLI {
534 private $extensions;
535
536 /**
537 * Constructor.
538 * @param $options array Options for script.
539 * @param $extension string The extension name (or names).
540 */
541 public function __construct( array $options, $extension ) {
542 if ( isset( $options['help'] ) ) {
543 echo $this->help();
544 exit( 1 );
545 }
546
547 if ( isset( $options['lang'] ) ) {
548 $this->code = $options['lang'];
549 } else {
550 global $wgLanguageCode;
551 $this->code = $wgLanguageCode;
552 }
553
554 if ( isset( $options['level'] ) ) {
555 $this->level = $options['level'];
556 }
557
558 $this->doLinks = isset( $options['links'] );
559
560 if ( isset( $options['wikilang'] ) ) {
561 $this->wikiCode = $options['wikilang'];
562 }
563
564 if ( isset( $options['whitelist'] ) ) {
565 $this->checks = explode( ',', $options['whitelist'] );
566 } elseif ( isset( $options['blacklist'] ) ) {
567 $this->checks = array_diff(
568 isset( $options['easy'] ) ? $this->easyChecks() : $this->defaultChecks(),
569 explode( ',', $options['blacklist'] )
570 );
571 } elseif ( isset( $options['easy'] ) ) {
572 $this->checks = $this->easyChecks();
573 } else {
574 $this->checks = $this->defaultChecks();
575 }
576
577 if ( isset( $options['output'] ) ) {
578 $this->output = $options['output'];
579 }
580
581 # Some additional checks not enabled by default
582 if ( isset( $options['duplicate'] ) ) {
583 $this->checks[] = 'duplicate';
584 }
585
586 $this->extensions = array();
587 $extensions = new PremadeMediawikiExtensionGroups();
588 $extensions->addAll();
589 if ( $extension == 'all' ) {
590 foreach ( MessageGroups::singleton()->getGroups() as $group ) {
591 if ( strpos( $group->getId(), 'ext-' ) === 0 && !$group->isMeta() ) {
592 $this->extensions[] = new extensionLanguages( $group );
593 }
594 }
595 } elseif ( $extension == 'wikimedia' ) {
596 $wikimedia = MessageGroups::getGroup( 'ext-0-wikimedia' );
597 foreach ( $wikimedia->wmfextensions() as $extension ) {
598 $group = MessageGroups::getGroup( $extension );
599 $this->extensions[] = new extensionLanguages( $group );
600 }
601 } elseif ( $extension == 'flaggedrevs' ) {
602 foreach ( MessageGroups::singleton()->getGroups() as $group ) {
603 if ( strpos( $group->getId(), 'ext-flaggedrevs-' ) === 0 && !$group->isMeta() ) {
604 $this->extensions[] = new extensionLanguages( $group );
605 }
606 }
607 } else {
608 $extensions = explode( ',', $extension );
609 foreach ( $extensions as $extension ) {
610 $group = MessageGroups::getGroup( 'ext-' . $extension );
611 if ( $group ) {
612 $extension = new extensionLanguages( $group );
613 $this->extensions[] = $extension;
614 } else {
615 print "No such extension $extension.\n";
616 }
617 }
618 }
619 }
620
621 /**
622 * Get the default checks.
623 * @return array A list of the default checks.
624 */
625 protected function defaultChecks() {
626 return array(
627 'untranslated', 'duplicate', 'obsolete', 'variables', 'empty', 'plural',
628 'whitespace', 'xhtml', 'chars', 'links', 'unbalanced',
629 );
630 }
631
632 /**
633 * Get the checks which check other things than messages.
634 * @return array A list of the non-message checks.
635 */
636 protected function nonMessageChecks() {
637 return array();
638 }
639
640 /**
641 * Get the checks that can easily be treated by non-speakers of the language.
642 * @return arrayA list of the easy checks.
643 */
644 protected function easyChecks() {
645 return array(
646 'duplicate', 'obsolete', 'empty', 'whitespace', 'xhtml', 'chars',
647 );
648 }
649
650 /**
651 * Get help.
652 * @return string The help string.
653 */
654 protected function help() {
655 return <<<ENDS
656 Run this script to check the status of a specific language in extensions, or all of them.
657 Command line settings are in form --parameter[=value], except for the first one.
658 Parameters:
659 * First parameter (mandatory): Extension name, multiple extension names (separated by commas), "all" for all the extensions, "wikimedia" for extensions used by Wikimedia or "flaggedrevs" for all FLaggedRevs extension messages.
660 * lang: Language code (default: the installation default language).
661 * help: Show this help.
662 * level: Show the following display level (default: 2).
663 * links: Link the message values (default off).
664 * wikilang: For the links, what is the content language of the wiki to display the output in (default en).
665 * whitelist: Do only the following checks (form: code,code).
666 * blacklist: Do not perform the following checks (form: code,code).
667 * easy: Do only the easy checks, which can be treated by non-speakers of the language.
668 Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
669 * untranslated: Messages which are required to translate, but are not translated.
670 * duplicate: Messages which translation equal to fallback
671 * obsolete: Messages which are untranslatable, but translated.
672 * variables: Messages without variables which should be used, or with variables which should not be used.
673 * empty: Empty messages.
674 * whitespace: Messages which have trailing whitespace.
675 * xhtml: Messages which are not well-formed XHTML (checks only few common errors).
676 * chars: Messages with hidden characters.
677 * links: Messages which contains broken links to pages (does not find all).
678 * unbalanced: Messages which contains unequal numbers of opening {[ and closing ]}.
679 Display levels (default: 2):
680 * 0: Skip the checks (useful for checking syntax).
681 * 1: Show only the stub headers and number of wrong messages, without list of messages.
682 * 2: Show only the headers and the message keys, without the message values.
683 * 3: Show both the headers and the complete messages, with both keys and values.
684
685 ENDS;
686 }
687
688 /**
689 * Execute the script.
690 */
691 public function execute() {
692 $this->doChecks();
693 }
694
695 /**
696 * Check a language and show the results.
697 * @param $code string The language code.
698 * @throws MWException
699 */
700 protected function checkLanguage( $code ) {
701 foreach ( $this->extensions as $extension ) {
702 $this->L = $extension;
703 $this->results = array();
704 $this->results[$code] = parent::checkLanguage( $code );
705
706 if ( !$this->isEmpty() ) {
707 echo $extension->name() . ":\n";
708
709 if ( $this->level > 0 ) {
710 switch ( $this->output ) {
711 case 'plain':
712 $this->outputText();
713 break;
714 case 'wiki':
715 $this->outputWiki();
716 break;
717 default:
718 throw new MWException( "Invalid output type $this->output" );
719 }
720 }
721
722 echo "\n";
723 }
724 }
725 }
726 }
727
728 // Blacklist some checks for some languages or some messages
729 // Possible keys of the sub arrays are: 'check', 'code' and 'message'.
730 $checkBlacklist = array(
731 array(
732 'check' => 'plural',
733 'code' => array( 'az', 'bo', 'cdo', 'dz', 'id', 'fa', 'gan', 'gan-hans',
734 'gan-hant', 'gn', 'hak', 'hu', 'ja', 'jv', 'ka', 'kk-arab',
735 'kk-cyrl', 'kk-latn', 'km', 'kn', 'ko', 'lzh', 'mn', 'ms',
736 'my', 'sah', 'sq', 'tet', 'th', 'to', 'tr', 'vi', 'wuu', 'xmf',
737 'yo', 'yue', 'zh', 'zh-classical', 'zh-cn', 'zh-hans',
738 'zh-hant', 'zh-hk', 'zh-sg', 'zh-tw', 'zh-yue'
739 ),
740 ),
741 array(
742 'check' => 'chars',
743 'code' => array( 'my' ),
744 ),
745 );