MediaWiki:Gadget-MsgToPortal.js

/* Adds a link on message pages to the respective language portal */ jQuery( function ( $ ) {	"use strict";

// FIXME: can't we re-use "nstab-portal"? var msgLanguagePortalTexti18n = { 'en': 'Language portal', // default 'de': 'Sprachenportal', 'fr': 'Portail de langue', 'ja': '言語ポータル', 'nl': 'Taalportaal', 'zh-hant': '語言入口', 'zh-hk': '語言入門', 'zh-mo': '語言入門', 'zh-hans': '语言门户' };	var msgLanguagePortalTooltipi18n = { 'en': 'Portal of this language', // default 'de': 'Portal dieser Sprache', 'fr': 'Portail de cette langue', 'ja': 'この言語のポータル', 'nl': 'Portaal van deze taal', 'zh-hant': '此語言的入口', 'zh-hk': '此語言的入門', 'zh-mo': '此語言的入門', 'zh-hans': '本语言的门户' };

var lang = mw.config.get( 'wgUserLanguage' ); var msgLanguagePortalText = msgLanguagePortalTexti18n[lang] || msgLanguagePortalTexti18n.en; var msgLanguagePortalTooltip = msgLanguagePortalTooltipi18n[lang] || msgLanguagePortalTooltipi18n.en;

if ( mw.config.get( 'wgTitle').indexOf( '/' ) === -1 ) { return; }	var title = mw.config.get( 'wgTitle' ); var code = title.substring( title .indexOf( "/" ) + 1 ); var ns = mw.config.get( 'wgNamespaceNumber' ); if ( ns == 8 || ns == 9 || ns > 1200 ) { // 8/9 = MediaWiki(_talk), 2100 and higher are other projects var username = encodeURIComponent( mw.config.get( 'wgTitle') ); mw.util.addPortletLink(			'p-tb',			mw.config.get( 'wgServer') + "/wiki/Portal:" + code,			msgLanguagePortalText,			"ca-contrib",			msgLanguagePortalTooltip + ' ("' + code + '")'		); } });