MediaWiki:Gadget-convenientDiscussions.js

From OpenStreetMap Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * This configuration might get outdated as the script evolves, so it's best to keep it up to date
 * by checking for the generator script and documentation updates from time to time. See the
 * documentation at
 * https://commons.wikimedia.org/wiki/Special:MyLanguage/User:Jack_who_built_the_house/Convenient_Discussions#Configuring_for_a_wiki.
 */

// <nowiki>

(function () {

function unique(item, i, arr) {
  return arr.indexOf(item) === i;
}

function getStrings() {
  const requests = [mw.config.get('wgUserLanguage'), mw.config.get('wgContentLanguage')]
    .filter(unique)
    .filter(function (lang) {
      return lang !== 'en';
    })
    .map(function (lang) {
      return mw.loader.getScript('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions-i18n/' + lang + '.js&action=raw&ctype=text/javascript');
    });

  // We assume it's OK to fall back to English if the translation is unavailable for any reason.
  return Promise.all(requests).catch(function () {});
}

window.convenientDiscussions = window.convenientDiscussions || {};
if (convenientDiscussions.config) return;


/* BEGINNING OF THE CONFIGURATION */

convenientDiscussions.config = {
	'messages': {
		'sun': 'Sun',
		'mon': 'Mon',
		'tue': 'Tue',
		'wed': 'Wed',
		'thu': 'Thu',
		'fri': 'Fri',
		'sat': 'Sat',
		'sunday': 'Sunday',
		'monday': 'Monday',
		'tuesday': 'Tuesday',
		'wednesday': 'Wednesday',
		'thursday': 'Thursday',
		'friday': 'Friday',
		'saturday': 'Saturday',
		'jan': 'Jan',
		'feb': 'Feb',
		'mar': 'Mar',
		'apr': 'Apr',
		'may': 'May',
		'jun': 'Jun',
		'jul': 'Jul',
		'aug': 'Aug',
		'sep': 'Sep',
		'oct': 'Oct',
		'nov': 'Nov',
		'dec': 'Dec',
		'january': 'January',
		'february': 'February',
		'march': 'March',
		'april': 'April',
		'may_long': 'May',
		'june': 'June',
		'july': 'July',
		'august': 'August',
		'september': 'September',
		'october': 'October',
		'november': 'November',
		'december': 'December',
		'january-gen': 'January',
		'february-gen': 'February',
		'march-gen': 'March',
		'april-gen': 'April',
		'may-gen': 'May',
		'june-gen': 'June',
		'july-gen': 'July',
		'august-gen': 'August',
		'september-gen': 'September',
		'october-gen': 'October',
		'november-gen': 'November',
		'december-gen': 'December',
		'timezone-utc': 'UTC',
		'parentheses': '($1)',
		'parentheses-start': '(',
		'parentheses-end': ')',
		'word-separator': ' ',
		'comma-separator': ', ',
		'colon-separator': ': ',
		'nextdiff': 'Newer edit →'
	},
	'contribsPage': 'Special:Contributions',
	'timezone': 'UTC',
	'useGlobalPreferences': false,
	'signatureEndingRegexp': / \(talk\)/
};

/* END OF THE CONFIGURATION */


if (!convenientDiscussions.isRunning) {
  convenientDiscussions.getStringsPromise = getStrings();
  mw.loader.getScript('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions.js&action=raw&ctype=text/javascript')
    .catch(function (e) {
      console.warn('Couldn\'t load Convenient Discussions.', e);
    });
}

}());

// </nowiki>