From: Bartosz DziewoƄski Date: Mon, 9 May 2016 22:04:15 +0000 (+0200) Subject: mw.widgets.CategoryCapsuleItemWidget: Handle non-English foreign wikis X-Git-Tag: 1.31.0-rc.0~7014^2 X-Git-Url: http://git.cyclocoop.org/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=17b6317374329e8da9ae9cc8f6ad9e7972bc069c;p=lhc%2Fweb%2Fwiklou.git mw.widgets.CategoryCapsuleItemWidget: Handle non-English foreign wikis To be precise: when the language of the foreign wiki is different than the language of the local wiki, and it's not English, things go bad when we're checking for page existence (to display blue/red link). Just assume that any namespace-like prefix is the 'Category' namespace. This is a horrible hack, but it's better than throwing exceptions. This doesn't fix the fact that suggestions in mw.widgets.CategorySelector are missing, but that isn't causing exceptions, so it can wait. Change-Id: I3ed11a9d7a1d87c0f43c0a988fe4a8db5b8a907c --- diff --git a/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js index 58115c3140..2eb84e633a 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js @@ -84,8 +84,11 @@ * @constructor * @inheritdoc */ - function ForeignTitle() { - ForeignTitle.parent.apply( this, arguments ); + function ForeignTitle( title, namespace ) { + // We only need to handle categories here... but we don't know the target language. + // So assume that any namespace-like prefix is the 'Category' namespace... + title = title.replace( /^(.+?)_*:_*(.*)$/, 'Category:$2' ); // HACK + ForeignTitle.parent.call( this, title, namespace ); } OO.inheritClass( ForeignTitle, mw.Title ); ForeignTitle.prototype.getNamespacePrefix = function () {