mw.widgets.CategoryCapsuleItemWidget: Handle non-English foreign wikis
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 9 May 2016 22:04:15 +0000 (00:04 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 9 May 2016 22:14:41 +0000 (00:14 +0200)
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

resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js

index 58115c3..2eb84e6 100644 (file)
         * @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 () {