MediaWiki:Common.js
Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.
- Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
- Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
- Internet Explorer/Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
- Opera: Presiona Ctrl+F5.
/* Any JavaScript here will be loaded for all users on every page load. */
// #region I18n accessor factory
// This takes in a module name and a localised string table (map[language -> map[name -> string]]),
// and returns a function to look-up a string by its name.
// Translations should either be put into the script's string table, or provided locally via
// [[MediaWiki:Common.js]].
// To provide a string locally, provide window.arkLocalI18n (map[module -> map[name -> string]]).
window.arkCreateI18nInterface = function(module, strings) {
var lang = mw.config.get('wgPageContentLanguage');
var localStrings = window.arkLocalI18n && window.arkLocalI18n[module];
return function (key) {
return ( // try from local store
(localStrings && localStrings[key])
// try from script store
|| (strings[lang] && strings[lang][key] || strings['en'][key])
// fallback
|| '<'+key+'>' );
};
};
window.arkCreateI18nInterfaceEx = function ( module, strings ) {
var lang = mw.config.get( 'wgPageContentLanguage' );
var localStrings = window.arkLocalI18n && window.arkLocalI18n[ module ];
return Object.assign(
{},
strings[ 'en' ],
strings[ lang ],
localStrings
);
};
// #endregion
// #region importArticles with transparent EN interwiki support
// Strip "en:" prefix on EN wiki, or prepend "u:" on translations
window.arkIsEnglishWiki = mw.config.get('wgContentLanguage') == 'en';
window.arkImportArticles = function ( articles ) {
var mLocal = [], mGlobal = [];
articles.forEach( function ( item ) {
if ( item.startsWith( 'en:' ) ) {
mGlobal.push( item.slice( 3 ) );
} else {
mLocal.push( item );
}
} );
if ( arkIsEnglishWiki ) {
mLocal = mLocal.concat( mGlobal );
mGlobal.length = 0;
}
// Load global modules
if ( mGlobal.length ) {
mw.loader.load( '/load.php?lang=en&modules=' + encodeURIComponent( mGlobal.join( '|' ) )
+ '&skin=vector&version=ztntf' + ( mw.config.get( 'debug' ) ? '&debug=1' : '' ) );
}
// Load local modules
if ( mLocal.length ) {
// Race warning: the ImportArticles extension script might be loaded after our script. Require it before executing the call.
mw.loader.using( 'ext.importarticles', function () {
importArticles( { type: 'script', articles: mLocal } );
} );
}
};