r42564 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42563‎ | r42564 | r42565 >
Date:17:35, 25 October 2008
Author:rotem
Status:old
Tags:
Comment:
Adding an option to do the 'easy' checks in the language checking script, i.e. the checks that a non-speaker of the language can usually fix.
Modified paths:
  • /trunk/phase3/maintenance/language/checkLanguage.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/checkLanguage.inc
@@ -27,22 +27,22 @@
2828 exit();
2929 }
3030
31 - if ( isset($options['lang']) ) {
 31+ if ( isset( $options['lang'] ) ) {
3232 $this->code = $options['lang'];
3333 } else {
3434 global $wgLanguageCode;
3535 $this->code = $wgLanguageCode;
3636 }
3737
38 - if ( isset($options['level']) ) {
 38+ if ( isset( $options['level'] ) ) {
3939 $this->level = $options['level'];
4040 }
4141
42 - $this->doLinks = isset($options['links']);
43 - $this->includeExif = !isset($options['noexif']);
44 - $this->checkAll = isset($options['all']);
 42+ $this->doLinks = isset( $options['links'] );
 43+ $this->includeExif = !isset( $options['noexif'] );
 44+ $this->checkAll = isset( $options['all'] );
4545
46 - if ( isset($options['wikilang']) ) {
 46+ if ( isset( $options['wikilang'] ) ) {
4747 $this->wikiCode = $options['wikilang'];
4848 }
4949
@@ -50,14 +50,16 @@
5151 $this->checks = explode( ',', $options['whitelist'] );
5252 } elseif ( isset( $options['blacklist'] ) ) {
5353 $this->checks = array_diff(
54 - $this->defaultChecks(),
 54+ isset( $options['easy'] ) ? $this->easyChecks() : $this->defaultChecks(),
5555 explode( ',', $options['blacklist'] )
5656 );
 57+ } elseif ( isset( $options['easy'] ) ) {
 58+ $this->checks = $this->easyChecks();
5759 } else {
5860 $this->checks = $this->defaultChecks();
5961 }
6062
61 - if ( isset($options['output']) ) {
 63+ if ( isset( $options['output'] ) ) {
6264 $this->output = $options['output'];
6365 }
6466
@@ -78,7 +80,7 @@
7981 }
8082
8183 /**
82 - * Get the non-message checks.
 84+ * Get the checks which check other things than messages.
8385 * @return A list of the non-message checks.
8486 */
8587 protected function nonMessageChecks() {
@@ -89,6 +91,17 @@
9092 }
9193
9294 /**
 95+ * Get the checks that can easily be treated by non-speakers of the language.
 96+ * @return A list of the easy checks.
 97+ */
 98+ protected function easyChecks() {
 99+ return array(
 100+ 'duplicate', 'obsolete', 'empty', 'whitespace', 'xhtml', 'chars', 'magic-old',
 101+ 'magic-over', 'magic-case', 'special-old',
 102+ );
 103+ }
 104+
 105+ /**
93106 * Get all checks.
94107 * @return An array of all check names mapped to their function names.
95108 */
@@ -183,6 +196,7 @@
184197 * wikilang: For the links, what is the content language of the wiki to display the output in (default en).
185198 * whitelist: Do only the following checks (form: code,code).
186199 * blacklist: Don't do the following checks (form: code,code).
 200+ * easy: Do only the easy checks, which can be treated by non-speakers of the language.
187201 * noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know that they are currently not translated and want to focus on other problems (default off).
188202 Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
189203 * untranslated: Messages which are required to translate, but are not translated.
@@ -452,20 +466,20 @@
453467 exit();
454468 }
455469
456 - if ( isset($options['lang']) ) {
 470+ if ( isset( $options['lang'] ) ) {
457471 $this->code = $options['lang'];
458472 } else {
459473 global $wgLanguageCode;
460474 $this->code = $wgLanguageCode;
461475 }
462476
463 - if ( isset($options['level']) ) {
 477+ if ( isset( $options['level'] ) ) {
464478 $this->level = $options['level'];
465479 }
466480
467 - $this->doLinks = isset($options['links']);
 481+ $this->doLinks = isset( $options['links'] );
468482
469 - if ( isset($options['wikilang']) ) {
 483+ if ( isset( $options['wikilang'] ) ) {
470484 $this->wikiCode = $options['wikilang'];
471485 }
472486
@@ -473,14 +487,16 @@
474488 $this->checks = explode( ',', $options['whitelist'] );
475489 } elseif ( isset( $options['blacklist'] ) ) {
476490 $this->checks = array_diff(
477 - $this->defaultChecks(),
 491+ isset( $options['easy'] ) ? $this->easyChecks() : $this->defaultChecks(),
478492 explode( ',', $options['blacklist'] )
479493 );
 494+ } elseif ( isset( $options['easy'] ) ) {
 495+ $this->checks = $this->easyChecks();
480496 } else {
481497 $this->checks = $this->defaultChecks();
482498 }
483499
484 - if ( isset($options['output']) ) {
 500+ if ( isset( $options['output'] ) ) {
485501 $this->output = $options['output'];
486502 }
487503
@@ -492,23 +508,23 @@
493509 $this->extensions = array();
494510 $extensions = new PremadeMediawikiExtensionGroups();
495511 $extensions->addAll();
496 - if( $extension == 'all' ) {
497 - foreach( MessageGroups::singleton()->getGroups() as $group ) {
498 - if( strpos( $group->getId(), 'ext-' ) === 0 && !$group->isMeta() ) {
 512+ if ( $extension == 'all' ) {
 513+ foreach ( MessageGroups::singleton()->getGroups() as $group ) {
 514+ if ( strpos( $group->getId(), 'ext-' ) === 0 && !$group->isMeta() ) {
499515 $this->extensions[] = new extensionLanguages( $group );
500516 }
501517 }
502 - } elseif( $extension == 'wikimedia' ) {
 518+ } elseif ( $extension == 'wikimedia' ) {
503519 $wikimedia = MessageGroups::getGroup( 'ext-0-wikimedia' );
504 - foreach( $wikimedia->wmfextensions() as $extension ) {
 520+ foreach ( $wikimedia->wmfextensions() as $extension ) {
505521 $group = MessageGroups::getGroup( $extension );
506522 $this->extensions[] = new extensionLanguages( $group );
507523 }
508524 } else {
509525 $extensions = explode( ',', $extension );
510 - foreach( $extensions as $extension ) {
 526+ foreach ( $extensions as $extension ) {
511527 $group = MessageGroups::getGroup( 'ext-' . $extension );
512 - if( $group ) {
 528+ if ( $group ) {
513529 $extension = new extensionLanguages( $group );
514530 $this->extensions[] = $extension;
515531 } else {
@@ -530,6 +546,24 @@
531547 }
532548
533549 /**
 550+ * Get the checks which check other things than messages.
 551+ * @return A list of the non-message checks.
 552+ */
 553+ protected function nonMessageChecks() {
 554+ return array();
 555+ }
 556+
 557+ /**
 558+ * Get the checks that can easily be treated by non-speakers of the language.
 559+ * @return A list of the easy checks.
 560+ */
 561+ protected function easyChecks() {
 562+ return array(
 563+ 'duplicate', 'obsolete', 'empty', 'whitespace', 'xhtml', 'chars',
 564+ );
 565+ }
 566+
 567+ /**
534568 * Get help.
535569 * @return The help string.
536570 */
@@ -546,7 +580,7 @@
547581 * wikilang: For the links, what is the content language of the wiki to display the output in (default en).
548582 * whitelist: Do only the following checks (form: code,code).
549583 * blacklist: Do not perform the following checks (form: code,code).
550 - * duplicate: Additionally check for messages which are translated the same to English (default off).
 584+ * easy: Do only the easy checks, which can be treated by non-speakers of the language.
551585 Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
552586 * untranslated: Messages which are required to translate, but are not translated.
553587 * duplicate: Messages which translation equal to fallback

Status & tagging log