From 44ada9ac71412562975c5dcefdb538109884e68b Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 31 Oct 2013 01:52:18 +0100 Subject: [PATCH] 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 --- .../dm/models/ve.dm.MWTemplateSpecModel.js | 36 +++---------------- .../dm/models/ve.dm.MWTransclusionModel.js | 3 +- .../ui/dialogs/ve.ui.MWTransclusionDialog.js | 3 -- 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js b/modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js index 30d5723988..13b6be5807 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js @@ -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; }; /** diff --git a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js index 5a306d7174..af86c7b3a6 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js @@ -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 ) { diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js index 0170c52ddf..183b984929 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js @@ -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 *