http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73048
Revision: 73048
Author: tparscal
Date: 2010-09-15 02:16:45 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Fixed basic message parser
Modified Paths:
--------------
trunk/phase3/resources/mediawiki/mediawiki.js
Modified: trunk/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- trunk/phase3/resources/mediawiki/mediawiki.js 2010-09-15 02:07:57 UTC
(rev 73047)
+++ trunk/phase3/resources/mediawiki/mediawiki.js 2010-09-15 02:16:45 UTC
(rev 73048)
@@ -173,19 +173,13 @@
/*
* 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;
};
/*
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs