dm.MWTemplateSpecModel: Resolve translations through the TemplateData API

Also removed comment in ui.MWTransclusionDialog that was
copied from dm.MWTemplateSpecModel.

Bug: 50888
Change-Id: I9dcfef3ae65fe716bae91f703f9169171448797a
This commit is contained in:
Timo Tijhof 2013-10-31 01:52:18 +01:00 committed by Krinkle
parent 211727a2fd
commit 44ada9ac71
3 changed files with 6 additions and 36 deletions

View file

@ -29,34 +29,6 @@ ve.dm.MWTemplateSpecModel = function VeDmMWTemplateSpecModel( template ) {
this.fill();
};
/* Static Methods */
/**
* Get the correct value from a message property.
*
* @method
* @static
* @param {string|Object|null} val Messsage or object with messages keyed by language
* @param {Mixed} [fallback=null] Value to use if message is not available
* @param {string} [lang] Language to prefer, user interface language will be used by default
* @returns {string} Message text or fallback if not available
*/
ve.dm.MWTemplateSpecModel.getMessage = function ( val, fallback, lang ) {
var i, len, langs = lang !== undefined ? [lang] : ve.init.platform.getUserLanguages();
if ( fallback === undefined ) {
fallback = null;
}
if ( ve.isPlainObject( val ) ) {
for ( i = 0, len = langs.length; i < len; i++ ) {
if ( val[langs[i]] ) {
return val[langs[i]];
}
}
return fallback;
}
return typeof val === 'string' ? val : fallback;
};
/* Methods */
/**
@ -126,7 +98,7 @@ ve.dm.MWTemplateSpecModel.prototype.fill = function () {
*/
ve.dm.MWTemplateSpecModel.prototype.getDefaultParameterSpec = function ( name ) {
return {
'label': { 'en': name },
'label': name,
'description': null,
'default': '',
'type': 'string',
@ -172,7 +144,7 @@ ve.dm.MWTemplateSpecModel.prototype.getLabel = function () {
* @returns {string|null} Template description or null if not available
*/
ve.dm.MWTemplateSpecModel.prototype.getDescription = function () {
return this.constructor.getMessage( this.description, null );
return this.description;
};
/**
@ -207,7 +179,7 @@ ve.dm.MWTemplateSpecModel.prototype.isParameterAlias = function ( name ) {
* @returns {string} Parameter label
*/
ve.dm.MWTemplateSpecModel.prototype.getParameterLabel = function ( name ) {
return this.constructor.getMessage( this.params[name].label, name );
return this.params[name].label || name;
};
/**
@ -218,7 +190,7 @@ ve.dm.MWTemplateSpecModel.prototype.getParameterLabel = function ( name ) {
* @returns {string|null} Parameter description
*/
ve.dm.MWTemplateSpecModel.prototype.getParameterDescription = function ( name ) {
return this.constructor.getMessage( this.params[name].description );
return this.params[name].description;
};
/**

View file

@ -164,7 +164,8 @@ ve.dm.MWTransclusionModel.prototype.fetch = function () {
'data': {
'format': 'json',
'action': 'templatedata',
'titles': titles.join( '|' )
'titles': titles.join( '|' ),
'lang': mw.config.get( 'wgUserLanguage' )
}
} )
.done( function ( data ) {

View file

@ -8,9 +8,6 @@
/**
* Dialog for inserting and editing MediaWiki transclusions.
*
* See https://raw.github.com/wikimedia/mediawiki-extensions-TemplateData/master/spec.templatedata.json
* for the latest version of the TemplateData specification.
*
* @class
* @extends ve.ui.MWDialog
*