Jump to content

User:Ohconfucius/script/EngvarB.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ohconfucius (talk | contribs) at 06:45, 19 May 2010 (+beta). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function BritEnglish(){
 var txt=document.editform.wpTextbox1;

txt.value=txt.value.replace(/aluminum/g, 'aluminium');
txt.value=txt.value.replace(/artifact/g, 'artefact');
txt.value=txt.value.replace(/(ana|cata|hydro|para)lyz(e|ing)/g, '$1lys$2');
txt.value=txt.value.replace(/diarrhea/g, 'diarrhoea');
txt.value=txt.value.replace(/(de|of)fense/g, '$1fence');
txt.value=txt.value.replace(/\bfuror\b/g, 'furore');
txt.value=txt.value.replace(/([\s-])gray/g, '$1grey');
//txt.value=txt.value.replace(/judgment/g, 'judgement');
txt.value=txt.value.replace(/jewelry/g, 'jewellery');
txt.value=txt.value.replace(/maneuver(ab|ed|ing)/g, 'manoeuvr$1');
txt.value=txt.value.replace(/maneuver/g, 'manoeuvre');
txt.value=txt.value.replace(/ped(iatric|ophil)/g, 'paed$1');
txt.value=txt.value.replace(/skeptic/g, 'sceptic');
txt.value=txt.value.replace(/vapor(s?\W)/g, 'vapour$1');

//composite words
//txt.value=txt.value.replace(/onstage/g, 'on-stage');
txt.value=txt.value.replace(/(break|clean|lock|pick)up/g, '$1-up');

 //latin words
txt.value=txt.value.replace(/gyneco/g, 'gynaeco');
txt.value=txt.value.replace(/hemo(globin|ly|phil)/g, 'haemo$1');
txt.value=txt.value.replace(/orthopedic/g, 'orthopaedic');
txt.value=txt.value.replace(/archeo/g, 'archaeo');
txt.value=txt.value.replace(/paleonto/g, 'palaeonto');
txt.value=txt.value.replace(/\benology/g, 'oenology');
txt.value=txt.value.replace(/\bestrogen/g, 'oestrogen');
txt.value=txt.value.replace(/\besthetic/g, 'aesthetic');
txt.value=txt.value.replace(/homeopath/g, 'homoeopath');
//txt.value=txt.value.replace(/medieval/g, 'mediaeval');
txt.value=txt.value.replace(/\brigor\b/g, 'rigour');
txt.value=txt.value.replace(/(an|leuk|septic|tox)emi(a|c)/g, '$1aemi$2'); 

 //'f' words
txt.value=txt.value.replace(/sulfur/g, 'sulphur');

// non-redundant e
txt.value=txt.value.replace(/(lik|liv|rat|sal|siz|shak)(able)/g, '$1e$2'); 

txt.value=txt.value.replace(/(clam|harb|neighb|rum|savi?)or(ed|ful|ing|less|ly|s?\W)/g, '$1our$2');
txt.value=txt.value.replace(/neighborhood/g, 'neighbourhood');
txt.value=txt.value.replace(/behavior(al|s?\W)/g, 'behaviour$1');
txt.value=txt.value.replace(/(fav|hon)or(abl[ey]|ed|ing|s?\W)/g, '$1our$2');
txt.value=txt.value.replace(/(\W)labor(ed|ing|s?\W)/g, '$1labour$2');
txt.value=txt.value.replace(/(col|flav|hum)or(ed|ful|fully|ing|less|lessly|s\W)/g, '$1our$2');

txt.value=txt.value.replace(/\b(calib|fib|goit|lust|mit|nit|reconnoit|sab|saltpet|spect|theat|tit)er(s?\b)/g, '$1re$2');
txt.value=txt.value.replace(/(cent|epicent|recent)er(ed|ing)/g, '$1r$2'); 
txt.value=txt.value.replace(/(centi|kilo|milli|-|\d\s)meter/g, '$1metre');
txt.value=txt.value.replace(/(centi|milli|deci|pico|hecto|\b)liter(s?\b)/g, '$1litre$2');
txt.value=txt.value.replace(/(dema|peda|mono|syna)gog(s?\W)/g, '$1gogue$2');
txt.value=txt.value.replace(/([^\\|\/|\-])(ana|cata|dia|epi|homo|mono|pro)log\b/g, '$1$2logue');
txt.value=txt.value.replace(/(\W[a-z]{3,12}[^s])iz(e[drs]?|ations?|ing)(\W)/g, '$1is$2$3');
txt.value=txt.value.replace(/(empha|synthe)siz(e[dr]|ing)/g, '$1sis$2'); 

txt.value=txt.value.replace(/(bev|jew|lev|mod|rev|trav)el(e[dr]|ing)/g, '$1ell$2'); 
txt.value=txt.value.replace(/(\b[a-z]{2,8}[^e])el(e[dr]|est|ing)\b/g, '$1ell$2');
txt.value=txt.value.replace(/(counci|counse|dia)l(e[dr]|ing|or)\b/gi, '$1ll$2');
txt.value=txt.value.replace(/(app|enthr|riv|sign|tot)al(e[dr]|ing)/g, '$1all$2'); 
txt.value=txt.value.replace(/ll(ful|ment)/g, 'l$1');

//reconvert special cases
txt.value=txt.value.replace(/(nobelpr|pics)ise/g, '$1ize');  

// Add a tag to the summary box
 var txt=document.editform.wpSummary;
    var summary = "per [[WP:ENGVAR|British English]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
//   document.forms.editform.wpMinoredit.checked = true;
   document.editform.wpDiff.click();
}


addOnloadHook(function () {
 if(document.forms.editform) {
//  addPortletLink('p-tb', 'javascript:CommonTerms()', 'Delink common terms', 't-dmy', 'Regexp common terms', '', '');
//  addPortletLink('p-tb', 'javascript:run_formatgeneral()', 'Add metric units', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
//  addPortletLink('p-tb', 'javascript:button_delink_dates_to_dmy()', 'Delink dates to dmy', 't-dmy', 'day month', '', '');
//  addPortletLink('p-tb', 'javascript:button_delink_dates_to_mdy()', 'Delink dates to mdy', 't-mdy', 'month day', '', '');

  addPortletLink('p-tb', 'javascript:BritEnglish()', 'British English', 't-dmy', 'converts to Brit English', '', '');
  }
});