Fixed basic message parser
authorTrevor Parscal <tparscal@users.mediawiki.org>
Wed, 15 Sep 2010 02:16:45 +0000 (02:16 +0000)
committerTrevor Parscal <tparscal@users.mediawiki.org>
Wed, 15 Sep 2010 02:16:45 +0000 (02:16 +0000)
resources/mediawiki/mediawiki.js

index 2b7f26f..24e0787 100644 (file)
@@ -173,19 +173,13 @@ window.mediaWiki = new ( function( $ ) {
        /*
         * Basic parser, can be replaced with something more robust
         */
-       this.parser = function( key, args ) {
-               if ( !( key in messages ) ) {
-                       return '<' + key + '>';
-               }
-               var msg = messages[key];
-               if ( typeof args == 'object' || typeof args == 'array' ) {
-                       for ( var a = 0; a < args.length; a++ ) {
-                               msg = msg.replace( '\$' + ( parseInt( a ) + 1 ), args[a] );
+       this.parser = function( text, options ) {
+               if ( typeof options === 'object' && typeof options.parameters === 'object' ) {
+                       for ( var p = 0; p < options.parameters.length; p++ ) {
+                               text = text.replace( '\$' + ( parseInt( p ) + 1 ), options.parameters[p] );
                        }
-               } else if ( typeof args == 'string' || typeof args == 'number' ) {
-                       msg = msg.replace( '$1', args );
                }
-               return msg;
+               return text;
        };
        
        /*