r36806 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36805‎ | r36806 | r36807 >
Date:09:03, 30 June 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* 2008-06-30:3 Check for unknown vars for mediawiki type
* Removed (mw ext) from extensions, no longer needed
Modified paths:
  • /trunk/extensions/Translate/MessageChecks.php (modified) (history)
  • /trunk/extensions/Translate/README (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/groups/MediaWikiExtensions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/groups/MediaWikiExtensions.php
@@ -129,7 +129,7 @@
130130 public function factory( $id ) {
131131
132132 $info = $this->groups[$id];
133 - $group = ExtensionMessageGroup::factory( $info['name'] . ' (mw ext)', $id );
 133+ $group = ExtensionMessageGroup::factory( $info['name'], $id );
134134 $group->setMessageFile( $info['file'] );
135135 if ( !empty($info['var']) ) $group->setVariableName( $info['var'] );
136136 if ( !empty($info['optional']) ) $group->setOptional( $info['optional'] );
Index: trunk/extensions/Translate/Translate.php
@@ -11,7 +11,7 @@
1212 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1313 */
1414
15 -define( 'TRANSLATE_VERSION', '9 (2008-06-30:2)' );
 15+define( 'TRANSLATE_VERSION', '9 (2008-06-30:3)' );
1616
1717 $wgExtensionCredits['specialpage'][] = array(
1818 'name' => 'Translate',
Index: trunk/extensions/Translate/MessageChecks.php
@@ -15,6 +15,7 @@
1616 'mediawiki' => array(
1717 array( __CLASS__, 'checkPlural' ),
1818 array( __CLASS__, 'checkParameters' ),
 19+ array( __CLASS__, 'checkUnknownParametersParameters' ),
1920 array( __CLASS__, 'checkBalance' ),
2021 array( __CLASS__, 'checkLinks' ),
2122 array( __CLASS__, 'checkXHTML' ),
@@ -90,6 +91,32 @@
9192 return false;
9293 }
9394
 95+ protected static function checkUnknownParameters( TMessage $message, &$desc = null ) {
 96+ $variables = array( '\$1', '\$2', '\$3', '\$4', '\$5', '\$6', '\$7', '\$8', '\$9' );
 97+
 98+ $missing = array();
 99+ $definition = $message->definition;
 100+ $translation= $message->translation;
 101+ if ( strpos( $definition, '$' ) === false ) return false;
 102+
 103+ for ( $i = 1; $i < 10; $i++ ) {
 104+ $pattern = '/\$' . $i . '/s';
 105+ if ( !preg_match( $pattern, $definition ) && preg_match( $pattern, $translation ) ) {
 106+ $missing[] = '$' . $i;
 107+ }
 108+ }
 109+
 110+ if ( $count = count($missing) ) {
 111+ global $wgLang;
 112+ $desc = array( 'translate-checks-parameters-unknown',
 113+ implode( ', ', $missing ),
 114+ $wgLang->formatNum($count) );
 115+ return true;
 116+ }
 117+
 118+ return false;
 119+ }
 120+
94121 /**
95122 * Checks if the translation has even number of opening and closing
96123 * parentheses. {, [ and ( are checked.
Index: trunk/extensions/Translate/README
@@ -34,6 +34,7 @@
3535
3636 == Changes in version 10 ==
3737
 38+* 2008-06-30:3 Check for unknown vars for mediawiki type
3839 * 2008-06-30:2 Checks for missing and unknown variables for FreeCol
3940 * 2008-06-30:1 More contrast in the new default page for Special translate
4041 * 2008-06-29:2 Branched core messages now load translations from trunk files too

Status & tagging log