From 17b6317374329e8da9ae9cc8f6ad9e7972bc069c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 10 May 2016 00:04:15 +0200 Subject: [PATCH] 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 --- .../mw.widgets.CategoryCapsuleItemWidget.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 () { -- 2.20.1