/*!
* Experimental advanced wikitext parser-emitter.
* See: https://www.mediawiki.org/wiki/Extension:UploadWizard/MessageParser for docs
/*!
* Experimental advanced wikitext parser-emitter.
* See: https://www.mediawiki.org/wiki/Extension:UploadWizard/MessageParser for docs
},
// Whitelist for allowed HTML elements in wikitext.
// Self-closing tags are not currently supported.
},
// Whitelist for allowed HTML elements in wikitext.
// Self-closing tags are not currently supported.
allowedHtmlElements: [],
// Key tag name, value allowed attributes for that tag.
// See Sanitizer::setupAttributeWhitelist
allowedHtmlElements: [],
// Key tag name, value allowed attributes for that tag.
// See Sanitizer::setupAttributeWhitelist
- * var userlink = $( '<a>' ).click( function () { alert( "hello!!" ) } );
- * $( 'p#headline' ).msg( 'hello-user', userlink );
+ * var $userlink = $( '<a>' ).click( function () { alert( "hello!!" ) } );
+ * $( 'p#headline' ).msg( 'hello-user', $userlink );
*
* N.B. replacements are variadic arguments or an array in second parameter. In other words:
* somefunction( a, b, c, d )
*
* N.B. replacements are variadic arguments or an array in second parameter. In other words:
* somefunction( a, b, c, d )
wikiText = this.settings.messages.get( key );
if ( typeof wikiText !== 'string' ) {
wikiText = '⧼' + key + '⧽';
wikiText = this.settings.messages.get( key );
if ( typeof wikiText !== 'string' ) {
wikiText = '⧼' + key + '⧽';
mw.jqueryMsg.HtmlEmitter = function ( language, magic ) {
var jmsg = this;
this.language = language;
mw.jqueryMsg.HtmlEmitter = function ( language, magic ) {
var jmsg = this;
this.language = language;
$.each( magic, function ( key, val ) {
jmsg[ key.toLowerCase() ] = function () {
return val;
$.each( magic, function ( key, val ) {
jmsg[ key.toLowerCase() ] = function () {
return val;
$.each( nodes, function ( i, node ) {
// Let jQuery append nodes, arrays of nodes and jQuery objects
// other things (strings, numbers, ..) are appended as text nodes (not as HTML strings)
$.each( nodes, function ( i, node ) {
// Let jQuery append nodes, arrays of nodes and jQuery objects
// other things (strings, numbers, ..) are appended as text nodes (not as HTML strings)
*
* @param {Array} nodes List of one element, integer, n >= 0
* @param {Array} replacements List of at least n strings
*
* @param {Array} nodes List of one element, integer, n >= 0
* @param {Array} replacements List of at least n strings
*/
replace: function ( nodes, replacements ) {
var index = parseInt( nodes[ 0 ], 10 );
*/
replace: function ( nodes, replacements ) {
var index = parseInt( nodes[ 0 ], 10 );
* Handles an (already-validated) HTML element.
*
* @param {Array} nodes Nodes to process when creating element
* Handles an (already-validated) HTML element.
*
* @param {Array} nodes Nodes to process when creating element
*/
htmlelement: function ( nodes ) {
var tagName, attributes, contents, $element;
*/
htmlelement: function ( nodes ) {
var tagName, attributes, contents, $element;
* So convert it back with the current language's convertNumber.
*
* @param {Array} nodes List of nodes, [ {string|number}, {string}, {string} ... ]
* So convert it back with the current language's convertNumber.
*
* @param {Array} nodes List of nodes, [ {string|number}, {string}, {string} ... ]
*/
plural: function ( nodes ) {
var forms, firstChild, firstChildText, explicitPluralFormNumber, formIndex, form, count,
explicitPluralForms = {};
*/
plural: function ( nodes ) {
var forms, firstChild, firstChildText, explicitPluralFormNumber, formIndex, form, count,
explicitPluralForms = {};
forms = nodes.slice( 1 );
for ( formIndex = 0; formIndex < forms.length; formIndex++ ) {
form = forms[ formIndex ];
forms = nodes.slice( 1 );
for ( formIndex = 0; formIndex < forms.length; formIndex++ ) {
form = forms[ formIndex ];
// This is a nested node, may be an explicit plural form like 5=[$2 linktext]
firstChild = form.contents().get( 0 );
if ( firstChild && firstChild.nodeType === Node.TEXT_NODE ) {
// This is a nested node, may be an explicit plural form like 5=[$2 linktext]
firstChild = form.contents().get( 0 );
if ( firstChild && firstChild.nodeType === Node.TEXT_NODE ) {
* - a gender string ('male', 'female' or 'unknown')
*
* @param {Array} nodes List of nodes, [ {string|mw.user}, {string}, {string}, {string} ]
* - a gender string ('male', 'female' or 'unknown')
*
* @param {Array} nodes List of nodes, [ {string|mw.user}, {string}, {string}, {string} ]
if ( maybeUser && maybeUser.options instanceof mw.Map ) {
gender = maybeUser.options.get( 'gender' );
} else {
if ( maybeUser && maybeUser.options instanceof mw.Map ) {
gender = maybeUser.options.get( 'gender' );
} else {
* Invoked by putting `{{grammar:form|word}}` in a message
*
* @param {Array} nodes List of nodes [{Grammar case eg: genitive}, {string word}]
* Invoked by putting `{{grammar:form|word}}` in a message
*
* @param {Array} nodes List of nodes [{Grammar case eg: genitive}, {string word}]
- return word && form && this.language.convertGrammar( word, form );
+ // These could be jQuery objects (passed as message parameters),
+ // in which case we can't transform them (like rawParams() in PHP).
+ if ( typeof form === 'string' && typeof word === 'string' ) {
+ return this.language.convertGrammar( word, form );
+ }
+ return word;
},
/**
* Tranform parsed structure into a int: (interface language) message include
* Invoked by putting `{{int:othermessage}}` into a message
*
},
/**
* Tranform parsed structure into a int: (interface language) message include
* Invoked by putting `{{int:othermessage}}` into a message
*
* @param {Array} nodes List of nodes
* @return {string} Other message
*/
'int': function ( nodes ) {
* @param {Array} nodes List of nodes
* @return {string} Other message
*/
'int': function ( nodes ) {
* separator, according to the current language.
*
* @param {Array} nodes List of nodes
* separator, according to the current language.
*
* @param {Array} nodes List of nodes
*/
formatnum: function ( nodes ) {
var isInteger = !!nodes[ 1 ] && nodes[ 1 ] === 'R',
number = nodes[ 0 ];
*/
formatnum: function ( nodes ) {
var isInteger = !!nodes[ 1 ] && nodes[ 1 ] === 'R',
number = nodes[ 0 ];
- return this.language.convertNumber( number, isInteger );
+ // These could be jQuery objects (passed as message parameters),
+ // in which case we can't transform them (like rawParams() in PHP).
+ if ( typeof number === 'string' || typeof number === 'number' ) {
+ return this.language.convertNumber( number, isInteger );
+ }
+ return number;
this.map[ this.format ] = mw.jqueryMsg.getMessageFunction( {
messages: this.map,
// For format 'escaped', escaping part is handled by mediawiki.js
this.map[ this.format ] = mw.jqueryMsg.getMessageFunction( {
messages: this.map,
// For format 'escaped', escaping part is handled by mediawiki.js