r57777 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57776‎ | r57777 | r57778 >
Date:17:19, 15 October 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
Hard check for broken plurals, skip them on export
Modified paths:
  • /trunk/extensions/Translate/FFS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/FFS.php
@@ -526,9 +526,7 @@
527527 $array = array();
528528 foreach ( $messages as $key => $value ) {
529529 $plurals = $this->unflattenPlural( $key, $value );
530 - if ( $plurals === false ) {
531 - $plurals = array( $key => $value );
532 - }
 530+ if ( $plurals === false ) continue;
533531
534532 foreach ( $plurals as $key => $value ) {
535533
@@ -567,8 +565,12 @@
568566 return false;
569567 }
570568
 569+ /**
 570+ * Override this. Return false to skip processing this value. Otherwise
 571+ * return array with keys and values.
 572+ */
571573 protected function unflattenPlural( $key, $value ) {
572 - return false;
 574+ return array( $key => $value );
573575 }
574576
575577 }
@@ -618,7 +620,7 @@
619621 */
620622 protected function unflattenPlural( $key, $message ) {
621623 // Quick escape
622 - if ( strpos( $message, '{{PLURAL' ) === false ) return false;
 624+ if ( strpos( $message, '{{PLURAL' ) === false ) return array( $key => $message );
623625
624626 // Replace all variables with placeholders. Possible source of bugs
625627 // if other characters that given below are used.
@@ -676,6 +678,11 @@
677679 $value = str_replace( array_keys( $placeholders ), array_values( $placeholders ), $value );
678680 }
679681
 682+ if ( !isset($alts["$key.other"]) ) {
 683+ wfWarn( "Other not set for key $key" );
 684+ return false;
 685+ }
 686+
680687 return $alts;
681688 }
682689

Status & tagging log