MediaWiki:Gadget-mySandbox.js

/* _____________________________________________________________________________ * |                                                                             | * |                    === WARNING: GLOBAL GADGET FILE ===                      | * |                 Changes to this page affects many users. | * |            Please discuss changes on the talk page before editing. | * |_____________________________________________________________________________| */

/** * Add a "My sandbox" link to the personal portlet menu. * Dependencies: mediawiki.util, mediawiki.Title, mediawiki.Uri * * @source mediawiki.org/wiki/Snippets/MySandbox * @version 2 * + localization according to user language */ ( function ( mw, $ ) {

$( function {        var conf, title, url;        var lang = mw.user.options.get( 'language' );

var transconf = { 'en': { subpageName: 'sandbox', portletLabel: 'Sandbox', portletTooltip: 'Go to your sandbox', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'ca': { subpageName: 'proves', portletLabel: 'Proves', portletTooltip: 'La vostra pàgina de proves', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'el': { subpageName: 'Το πρόχειρό μου', portletLabel: ' Το πρόχειρό μου ', portletTooltip: 'Η δικής σας σελίδα δοκιμών', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'es': { subpageName: 'zona de pruebas', portletLabel: 'Zona de pruebas', portletTooltip: 'Ir a tu zona de pruebas', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload/es', editintroPagename: 'Template:User_sandbox' },           'fa': { subpageName: 'صفحهٔ تمرین', portletLabel: 'صفحهٔ تمرین', portletTooltip: 'رفتن به صفحهٔ تمرین', // Please don't translate the part below editintroPagename: 'Template:User_sandbox', preloadPagename: 'Template:User_sandbox/preload' },           'fi': { subpageName: 'sandbox', portletLabel: 'Hiekkalaatikko', portletTooltip: 'Siirry hiekkalaatikollesi', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'fr': { subpageName: 'brouillon', portletLabel: 'Brouillon', portletTooltip: 'Accéder à votre brouillon', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'gl': { subpageName: 'zona de probas', portletLabel: 'Zona de probas', portletTooltip: 'Ir á túa zona de probas', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload/gl', editintroPagename: 'Template:User_sandbox' },           'nl': { subpageName: 'zandbak', portletLabel: 'Zandbak', portletTooltip: 'Ga naar je zandbak', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'ko': { subpageName: '연습장', portletLabel: '연습장', portletTooltip: '귀하의 사용자 연습장으로 이동합니다', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'mk': { subpageName: 'песочник', portletLabel: 'Песочник', portletTooltip: 'Одете на вашиот песочник', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'pl': { subpageName: 'brudnopis', portletLabel: 'Brudnopis', portletTooltip: 'Idź do swojego brudnopisu', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'pt': { subpageName: 'testes', portletLabel: 'Testes', portletTooltip: 'Ir para sua página de testes', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'pt-br': { subpageName: 'testes', portletLabel: 'Testes', portletTooltip: 'Ir para sua página de testes', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'sv': { subpageName: 'sandlåda', portletLabel: 'Sandlåda', portletTooltip: 'Gå till din sandlåda', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'uk': { subpageName: 'Чернетка', portletLabel: 'Чернетка', portletTooltip: 'Ваша чернетка', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'zh-hans': { subpageName: '沙盒', portletLabel: '沙盒', portletTooltip: '打开你的沙盒', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' },           'zh-hant': { subpageName: '沙盒', portletLabel: '沙盒', portletTooltip: '打開你的沙盒', // Please don't translate the part below preloadPagename: 'Template:User_sandbox/preload', editintroPagename: 'Template:User_sandbox' }       };        if ( transconf [ lang ] ) { conf = transconf[ lang ]; } else { conf = transconf[ 'en' ]; }       // Don't alter the code below

// Use Special:MyPage (as opposed to mw.user.getName) so that it       // works for logged-out users as well. title = new mw.Title( 'Special:MyPage/' + conf.subpageName );

url = new mw.Uri( title.getUrl ); url.extend({           action: 'edit',            redlink: 1,            editintro: new mw.Title( conf.editintroPagename ),            preload: new mw.Title( conf.preloadPagename )        });

mw.util.addPortletLink(           'p-personal',            url,            conf.portletLabel,            'pt-mysandbox',            conf.portletTooltip,            null,            '#pt-preferences'        ); }); }( mediaWiki, jQuery ) );