r38199 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38198‎ | r38199 | r38200 >
Date:18:15, 29 July 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Show variable holders in definitions
Modified paths:
  • /trunk/extensions/Translate/tag/Tag.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/Tag.php
@@ -131,7 +131,7 @@
132132 // Do in-place replace of variables, copy to keep $section intact for
133133 // the replace later
134134 $replace = $section;
135 - $this->extractVariablesFromSection( $replace, true );
 135+ $this->extractVariablesFromSection( $replace, 'replace' );
136136 $replace = '<div class="mw-translate-other">' . "\n" . $replace . "\n". '</div>';
137137 $input = str_replace( $section, $replace, $input );
138138 $input = str_replace( $match['holder'], '', $input );
@@ -162,7 +162,10 @@
163163 // Store array or replace, replacement for easy replace afterwards
164164 $vars[$id] = array( '$' . $id, $match['value'] );
165165 // If requested, subst them immediately
166 - if ( $subst ) $text = str_replace( $match[0], $match['value'], $text );
 166+ if ( $subst === 'replace' )
 167+ $text = str_replace( $match[0], $match['value'], $text );
 168+ elseif ( $subst === 'holder' )
 169+ $text = str_replace( $match[0], '$' . $id, $text );
167170 }
168171
169172 return $vars;
@@ -246,6 +249,7 @@
247250 $key = $match['id'];
248251 $contents = str_replace( $match['holder'], '', $match['section'] );
249252 list( , $key ) = explode( ':', $obj->getTranslationPage( $title, $key ), 2);
 253+ $obj->extractVariablesFromSection( $contents, 'holder' );
250254 $defs[$key] = $contents;
251255 }
252256

Status & tagging log