ve.ce.MWTransclusionNode: Pass number of templates to context

Fixing <visualeditor-dialog-transclusion-contextitem-description>.

Bug: T109564
Change-Id: Icdf762b3761227c3fcedefc947ffc512520cff76
This commit is contained in:
Alex Monk 2015-08-19 17:05:17 +01:00 committed by James D. Forrester
parent c0d2546617
commit b5dd86685b
3 changed files with 18 additions and 6 deletions

View file

@ -51,9 +51,13 @@ ve.ce.MWTransclusionNode.static.primaryCommandName = 'transclusion';
/* Static Methods */
/**
* @inheritdoc
* Get a list of descriptions of template parts in a transclusion node
*
* @static
* @param {ve.dm.Node} model Node model
* @return {string[]} List of template part descriptions
*/
ve.ce.MWTransclusionNode.static.getDescription = function ( model ) {
ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions = function ( model ) {
var i, len, part,
parts = model.getPartsList(),
words = [];
@ -65,11 +69,18 @@ ve.ce.MWTransclusionNode.static.getDescription = function ( model ) {
}
}
return words
return words;
};
/**
* @inheritdoc
*/
ve.ce.MWTransclusionNode.static.getDescription = function ( model ) {
return this.getTemplatePartDescriptions( model )
.map( function ( template ) {
var title = mw.Title.newFromText( template, mw.config.get( 'wgNamespaceIds' ).template );
if ( title ) {
return title.getRelativeText( 10 );
return title.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template );
} else {
return template;
}

View file

@ -205,7 +205,7 @@
"visualeditor-dialog-transclusion-add-param": "Label for button that adds a parameter to a transcluded template.",
"visualeditor-dialog-transclusion-add-template": "Label for button that adds the specified template to the page.\n{{Identical|Add template}}",
"visualeditor-dialog-transclusion-content": "Label for editor of content between transclusion parts.\n{{Identical|Content}}",
"visualeditor-dialog-transclusion-contextitem-description": "Message shown to an editor when they click on a template or group of templates that form a transclusion, listing the template(s) from which the transclusion is constructed.\n\n* $1 the name of the template, or a list of the names of the templates if there are multiple.",
"visualeditor-dialog-transclusion-contextitem-description": "Message shown to an editor when they click on a template or group of templates that form a transclusion, listing the template(s) from which the transclusion is constructed.\n\n* $1 the name of the template, or a list of the names of the templates if there are multiple.\n* $2 - number of templates for PLURAL support.",
"visualeditor-dialog-transclusion-deprecated-parameter": "Tooltip for deprecated parameter indicator",
"visualeditor-dialog-transclusion-deprecated-parameter-description": "Label describing that a parameter is deprecated.\n\nParameters:\n* $1 - Description given in TemplateData for why parameter is deprecated, which may be empty.",
"visualeditor-dialog-transclusion-loading": "Title for the transclusion dialog while its contents are loading.\n{{Identical|Loading}}",

View file

@ -69,7 +69,8 @@ ve.ui.MWTransclusionContextItem.static.isCompatibleWith =
ve.ui.MWTransclusionContextItem.prototype.getDescription = function () {
return ve.msg(
'visualeditor-dialog-transclusion-contextitem-description',
ve.ce.MWTransclusionNode.static.getDescription( this.model )
ve.ce.MWTransclusionNode.static.getDescription( this.model ),
ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions( this.model ).length
);
};