r73048 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73047‎ | r73048 | r73049 >
Date:02:16, 15 September 2010
Author:tparscal
Status:ok
Tags:
Comment:
Fixed basic message parser
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -173,19 +173,13 @@
174174 /*
175175 * Basic parser, can be replaced with something more robust
176176 */
177 - this.parser = function( key, args ) {
178 - if ( !( key in messages ) ) {
179 - return '<' + key + '>';
180 - }
181 - var msg = messages[key];
182 - if ( typeof args == 'object' || typeof args == 'array' ) {
183 - for ( var a = 0; a < args.length; a++ ) {
184 - msg = msg.replace( '\$' + ( parseInt( a ) + 1 ), args[a] );
 177+ this.parser = function( text, options ) {
 178+ if ( typeof options === 'object' && typeof options.parameters === 'object' ) {
 179+ for ( var p = 0; p < options.parameters.length; p++ ) {
 180+ text = text.replace( '\$' + ( parseInt( p ) + 1 ), options.parameters[p] );
185181 }
186 - } else if ( typeof args == 'string' || typeof args == 'number' ) {
187 - msg = msg.replace( '$1', args );
188182 }
189 - return msg;
 183+ return text;
190184 };
191185
192186 /*

Status & tagging log