User:BPositive/alignTranslations.js

mw.loader.using( ['jquery.ui.dialog', 'mediawiki.api'], function {

/* Alright - 1. This script just tries to align section headers as of now 2. Assuming we have all the translation units with us, and an array sectionHeaders_T, which contains the section headers out of these translation units (I can extract these, only when I have the translation units available in this code) 3. The script would match only if section header in source language is present in sectionHeaders_T array. 4. Also, I need to use the revision before FuzzyBot's edit. Will do that later in a few hours $(document).ready(function{		var sourceSections, translatedSections;	   var api_1 = new mw.Api;	    api_1.get ({ action:'parse', prop: 'sections', format: 'json', page: 'Extension:ParserFunctions' }).done ( function( data ) { sourceSections = data.parse.sections; console.log("Source language sections are:"); for(var i=0; i < sourceSections.length; i++){ console.log(sourceSections[i].line); }   		  var api_2 = new mw.Api; api_2.get ({			       action:'parse',			        prop: 'sections',			        format: 'json',			        page: 'Extension:ParserFunctions/pl'			    }).done ( function( data ) {			    	translatedSections = data.parse.sections;			    	console.log("Translated language sections are:");		    		for(var i=0; i < translatedSections.length; i++){		    			console.log(translatedSections[i].line);		    		}		    			if(sourceSections.length != translatedSections.length){			    		console.log("Number of sections not equal. Mismatches might happen");			    	}			    	else{	//They are equal. This else can be removed to still do some additional checks and match, if possible			    		for(var i=0; i < translatedSections.length; i++){		    			//if(sectionHeaders_T.indexOf(sectionSections[i]) > -1){		    				console.log(sourceSections[i].line + " matched with " + translatedSections[i].line);		    			//}	    			} }				   });

});	   }); });