Jump to content

User:Utcursch/Migrate Infobox Indian Jurisdiction to Infobox settlement/main.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Utcursch (talk | contribs) at 10:56, 30 May 2012 (m). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
/**
 * A quick-and-dirty solution to migrate the Infobox Indian Jurisdiction to Infobox settlement
 *
 * @author User:Utcursch
 */

/**
 * Replaces Infobox Indian Jurisdiction (if found) with Infobox settlement
 */
migrateIIJ.migrateInfoboxIJ = function () {
	// regular expression to parse Infobox Indian Jurisdiction
	var regex = /{{Infobox Indian Jurisdiction[^{]*?({{[^}]*?}}[\s\S]*?)*}}/gmi

	// get the article content
	var orig_article_text = document.getElementById("wpTextbox1").value;

	// get the infobox text
	var arr_infobox_text = orig_article_text.match(regex);

	// Infobox Indian Jurisdiction not found
	if (arr_infobox_text == null) {
		return;
	}

	// get infobox text
	var infobox_text = arr_infobox_text[0];

	// parse original infobox
	orig_infobox_params = migrateIIJ.parseInfobox(infobox_text);

	// create Infobox settlement
	var new_infobox_text = migrateIIJ.prepareInfoboxSettlement(orig_infobox_params);

	// replace original infobox with the new one
	var new_article_text = orig_article_text.replace(regex, new_infobox_text);

	// Insert Infobox settlement
	document.getElementById("wpTextbox1").value = new_article_text;

	// Provide an edit summary
	var summary = "converted"
	if (document.getElementById("wpSummary")) {
		document.getElementById("wpSummary").value = "[[User:Utcursch/Migrate Infobox Indian Jurisdiction to Infobox settlement|Migrated Infobox Indian Jurisdiction to Infobox settlement]]";
	}
}


/**
 * Build the Infobox settlement string
 *
 * @param infobox_text the infobox string
 *     {{Infobox Indian Jurisdiction ...  }}
 *
 * @return an object contaning the infobox parameters and values
 *     orig_infobox_params["parameter"] = "value"
 */
migrateIIJ.parseInfobox = function(infobox_text) {
	// to store
	var temp_param_arr = [];

	var paramRegexp = /\s*\|[^{}|]*?((?:{{[^{}]*}}|\[?\[[^[\]]*\]?\])?[^[\]{}|]*)*/g;

	// an array of all the parameter key-value pairs
    var temp_param_arr = infobox_text.match(paramRegexp);

    if (!temp_param_arr) {
		return;
	}

	var orig_infobox_params = {};

	// for each parameter key-value pair
	for (var i = 0; i < temp_param_arr.length; i++) {

		// something like "nickname = foo<ref>{{cite web | url = x | title = y }}"
		// the regex turns "|nickname = xyz" into "nickname = xyz"
		var key_value_str = temp_param_arr[i].replace(/^\s*\|/,"");

		// something like "| nickname = foo<ref>{{cite web | url = x | title = y }}"
		key_value_str = key_value_str

		// the index of "=" in the key value string
		var index_eq = key_value_str.indexOf("=");

		// something like "nickname"
		var key = key_value_str.substr(0, index_eq).trim();

		// something like "foo<ref>{{cite web | url = x | title = y }}"
		var value = key_value_str.substr(index_eq + 1).trim();

		orig_infobox_params[key] = value;
	}

	return orig_infobox_params;
}


/**
 * Build the Infobox settlement string
 *
 * @return an object contaning the Infobox settlement parameters and values
 *     (orig_infobox_params["parameter"] = "value"
 */
migrateIIJ.prepareInfoboxSettlement = function (orig_infobox_params) {
	// Location map
	var pushpin_map = "India";
	if (orig_infobox_params["state_name"]) {
		pushpin_map = "India " + orig_infobox_params["state_name"];
	}

	// Governing body
	var governing_body = "";
	if (orig_infobox_params["civic_agency"]) {
		governing_body = orig_infobox_params["civic_agency"];
	} else if (orig_infobox_params["planning_agency"]) {
		governing_body = orig_infobox_params["planning_agency"];
	}

	// make list of subdivisions
	var subdivisions = [];
	if (orig_infobox_params["state_name"]) {
		subdivisions["State"] = orig_infobox_params["state_name"];
	}
	if (orig_infobox_params["region"]) {
		subdivisions["Region"] = orig_infobox_params["region"];
	}
	if (orig_infobox_params["division"]) {
		subdivisions["Division"] = orig_infobox_params["division"];
	}
	if (orig_infobox_params["district"]) {
		subdivisions["District"] = orig_infobox_params["district"];
	}
	if (orig_infobox_params["metro"]) {
		subdivisions["Metro"] = orig_infobox_params["metro"];
	}
	if (orig_infobox_params["corp_zone"]) {
		subdivisions["Zone"] = orig_infobox_params["corp_zone"];
	}
	if (orig_infobox_params["corp_ward"]) {
		subdivisions["Ward"] = orig_infobox_params["corp_ward"];
	}
	for (var i = 1; i <= 3; i++ ) {
		if (orig_infobox_params["jurisdiction_title_" + i]) {
			var title = orig_infobox_params["jurisdiction_title_" + i];
			subdivisions[title] = orig_infobox_params["jurisdiction_name_" + i];
		}
	}

	// make list of languages
	var languages = [];
	if (orig_infobox_params["official_languages"]) {
		languages["Official"] = orig_infobox_params["official_languages"];
	} else {
		var state_name = orig_infobox_params["state_name"] ? orig_infobox_params["state_name"] : "";

		// strip [[]]
		state_name = state_name.replace("[[", "");
		state_name = state_name.replace("]]", "");

		if (state_name != "") {
			languages["Official"] = getOfficialLanguage(state_name);
		}
	}
	if (orig_infobox_params["regional_languages"]) {
		languages["Regional"] = orig_infobox_params["regional_languages"];
	}
	if (orig_infobox_params["languages"]) {
		var title = "Other languages";
		if (orig_infobox_params["languages_type"]) {
			title = orig_infobox_params["languages_type"];
		}
		languages[title] = orig_infobox_params["languages"];
	}

	// make list of other information
	var other_info = [];
	if (orig_infobox_params["districts"]) {
		other_info["No. of districts"] = orig_infobox_params["districts"];
	}
	if (orig_infobox_params["coastline"]) {
		other_info["Coastline"] = "{{Convert|" + orig_infobox_params["coastline"] + "|km|mi}}";
	}
	if (orig_infobox_params["coastline"]) {
		other_info["Coastline"] = "{{Convert|" + orig_infobox_params["coastline"] + "|km|mi}}";
	}
	if (orig_infobox_params["largest_city"]) {
		other_info["Largest city"] = orig_infobox_params["largest_city"];
	}
	if (orig_infobox_params["largest_metro"]) {
		other_info["Largest metro"] = orig_infobox_params["largest_metro"];
	}
	if (orig_infobox_params["nearest_city"]) {
		other_info["Nearest city"] = orig_infobox_params["nearest_city"];
	}
	if (orig_infobox_params["sex_ratio"]) {
		other_info["Sex ratio"] = orig_infobox_params["sex_ratio"];
	}
	if (orig_infobox_params["HDI"]) {
		other_info["HDI"] = orig_infobox_params["HDI"];
		if (orig_infobox_params["HDI_rank"]) {
			other_info["HDI Rank"] = orig_infobox_params["HDI_rank"];
		}
		if (orig_infobox_params["HDI_year"]) {
			other_info["HDI Year"] = orig_infobox_params["HDI_year"];
		}
		if (orig_infobox_params["HDI_category"]) {
			other_info["HDI Category"] = orig_infobox_params["HDI_category"];
		}
	}
	if (orig_infobox_params["literacy"]) {
		other_info["Literacy"] = orig_infobox_params["literacy"];
	}
	if (orig_infobox_params["x"]) {
		other_info["Literacy rank"] = orig_infobox_params["literacy_rank"];
	}
	if (orig_infobox_params["x"]) {
		other_info["Male literacy"] = orig_infobox_params["literacy_male"];
	}
	if (orig_infobox_params["x"]) {
		other_info["Female literacy"] = orig_infobox_params["literacy_female"];
	}
	if (orig_infobox_params["legislature_type"]) {
		other_info["Legislature type"] = orig_infobox_params["legislature_type"];
	}
	if (orig_infobox_params["legislature_strength"]) {
		other_info["Legislature Strength"] = orig_infobox_params["legislature_strength"];
	}
	if (orig_infobox_params["parliament_const"]) {
		other_info["[[Lok Sabha]] Constituency"] = orig_infobox_params["parliament_const"];
	}
	if (orig_infobox_params["assembly_const"]) {
		other_info["[[Rajya Sabha]] constituency"] = orig_infobox_params["assembly_const"];
	}
	if (orig_infobox_params["planning_agency"]) {
		other_info["Planning agency"] = orig_infobox_params["planning_agency"];
	}
	if (orig_infobox_params["civic_agency"]) {
		other_info["Civic agency"] = orig_infobox_params["civic_agency"];
	}
	if (orig_infobox_params["iucn_category"]) {
		other_info["[[IUCN protected area categories|IUCN category]]"] = orig_infobox_params["iucn_category"];
	}
	for (var i = 1; i <= 4; i++ ) {
		if (orig_infobox_params["destination_" + i]) {
			var distance_title = "Distance from " + orig_infobox_params["destination_" + i];

			var distance_value = "";

			if (orig_infobox_params["distance_" + i]) {
				distance_value += ("{{convert|" + orig_infobox_params["distance_" + i] + "|km|mi}}");
			}
			if (orig_infobox_params["direction_" + i]) {
				distance_value += (" " + orig_infobox_params["direction_" + i]);
			}
			if (orig_infobox_params["mode_" + i]) {
				distance_value += (" (" + orig_infobox_params["mode_" + i] + ")");
			}

			other_info[distance_title] = distance_value;
		}
	}

	for (var i = 1; i <= 4; i++ ) {
		if (orig_infobox_params["blank_title_" + i]) {
			var title = orig_infobox_params["blank_title_" + i];
			other_info[title] = orig_infobox_params["blank_value_" + i];
		}
	}

	// make list of climate information
	var climate = [];
	if (orig_infobox_params["climate"]) {
		climate["[[Climate of India|Climate]]"] = "[[Climatic regions of India|" + orig_infobox_params["climate"] + "]] <small>([[Köppen climate classification|Köppen]])</small>";
	}
	if (orig_infobox_params["precip"]) {
		climate["[[Precipitation (meteorology)|Precipitation]]"] = "{{convert|" + orig_infobox_params["precip"] + "|mm|in}}";
	}
	if (orig_infobox_params["temp_annual"]) {
		climate["Avg. annual temperature"] = "{{convert|" + orig_infobox_params["temp_annual"] + "|°C|°F}}";
	}
	if (orig_infobox_params["temp_summer"]) {
		climate["Avg. summer temperature"] = "{{convert|" + orig_infobox_params["temp_summer"] + "|°C|°F}}";
	}
	if (orig_infobox_params["temp_winter"]) {
		climate["Avg. winter temperature"] = "{{convert|" + orig_infobox_params["temp_winter"] + "|°C|°F}}";
	}

	var new_infobox_str =
		"{{Infobox settlement"         + "\n" +
		"| name                    = " + wgPageName.replace("_", " ") + "\n" +
		"| native_name             = " + (orig_infobox_params["native_name"] ? orig_infobox_params["native_name"] : "") + "\n" +
		"| native_name_lang        = " + (orig_infobox_params["native_name_lang"] ? orig_infobox_params["native_name_lang"] : "") + "\n" +
		"| other_name              = " + (orig_infobox_params["other_name"] ? orig_infobox_params["other_name"] : "") + "\n" +
		"| settlement_type         = " + (orig_infobox_params["type"] ? orig_infobox_params["type"] : "") + "\n" +
		"| image_skyline           = " + (orig_infobox_params["skyline"] ? orig_infobox_params["skyline"] : "") + "\n" +
		"| image_alt               = " + (orig_infobox_params["skyline_alt"] ? orig_infobox_params["skyline_alt"] : "") + "\n" +
		"| image_caption           = " + (orig_infobox_params["skyline_caption"] ? orig_infobox_params["skyline_caption"] : "") + "\n";

	if (orig_infobox_params["seal"]) {
		new_infobox_str +=
		"| image_seal              = " + orig_infobox_params["seal"] + "\n" +
		"| seal_size               = " + (orig_infobox_params["seal_size"] ? orig_infobox_params["seal_size"] : "") + "\n" +
		"| seal_alt                = " + (orig_infobox_params["seal_alt"] ? orig_infobox_params["seal_alt"] : "") + "\n";
	}

	new_infobox_str +=
		"| nickname                = " + (orig_infobox_params["nickname"] ? orig_infobox_params["nickname"] : "") + "\n" +
		"| map_alt                 = " + (orig_infobox_params["base_map_alt"] ? orig_infobox_params["base_map_alt"] : "") + "\n" +
		"| map_caption             = " + "\n" +
		"| pushpin_map             = " + (orig_infobox_params["latd"] ? pushpin_map : ("<!--" + pushpin_map + "-->")) + "\n" +
		"| pushpin_label_position  = " + (orig_infobox_params["locator_position"] ? orig_infobox_params["locator_position"] : "") + "\n" +
		"| pushpin_map_alt         = " + "\n" +
		"| pushpin_map_caption     = " + (orig_infobox_params["map_caption"] ? orig_infobox_params["map_caption"] : "") + "\n" +
		"| latd                    = " + (orig_infobox_params["latd"] ? orig_infobox_params["latd"] : "") + "\n" +
		"| latm                    = " + (orig_infobox_params["latm"] ? orig_infobox_params["latm"] : "") + "\n" +
		"| lats                    = " + (orig_infobox_params["lats"] ? orig_infobox_params["lats"] : "") + "\n" +
		"| latNS                   = " + "N\n" +
		"| longd                   = " + (orig_infobox_params["longd"] ? orig_infobox_params["longd"] : "") + "\n" +
		"| longm                   = " + (orig_infobox_params["longm"] ? orig_infobox_params["longm"] : "") + "\n" +
		"| longs                   = " + (orig_infobox_params["longs"] ? orig_infobox_params["longs"] : "") + "\n" +
		"| longEW                  = " + "E\n" +
		/*
		"| coor_pinpoint           = " + "\n" +
		"| coordinates_type        = " + "\n" +
		*/
		"| coordinates_display     = inline,title" + "\n" +
		/*
		"| coordinates_footnotes   = " + "\n" +
		*/
		"| subdivision_type        = Country" + "\n" +
		"| subdivision_name        = " + "India\n";


	var n_subdiv = 1; // number of subdivisions
	for (var title in subdivisions) {
		new_infobox_str += (
		"| subdivision_type" + n_subdiv + "       = " + title + "\n" +
		"| subdivision_name" + n_subdiv + "       = " + subdivisions[title] + "\n"
		);
		n_subdiv++;
	}

	new_infobox_str +=
		"| established_title       = " + (orig_infobox_params["established_title"] ? orig_infobox_params["established_title"] : "") + "\n" +
		"| established_date        = " + (orig_infobox_params["established_date"] ? orig_infobox_params["established_date"] : "") + "\n" +
		"| founder                 = " + "\n" +
		"| named_for               = " + "\n";

	if (orig_infobox_params["taluk_names"]) {
		new_infobox_str +=
		"| parts_type              = [[Taluka]]s" + "\n" +
		"| parts                   = " + orig_infobox_params["taluk_names"] + "\n";
	}

	if (orig_infobox_params["capital"]) {
		new_infobox_str +=
		"| seat_type               = Capital" + "\n" +
		"| seat                    = " + orig_infobox_params["capital"] + "\n";
	}
	if (orig_infobox_params["hq"]) {
		new_infobox_str +=
		"| seat_type               = Headquarters" + "\n" +
		"| seat                    = " + orig_infobox_params["hq"] + "\n";
	}

	new_infobox_str +=
		"| government_type         = " + "\n" +
		"| governing_body          = " + governing_body + "\n";

	if (orig_infobox_params["leader_title"]) {
		new_infobox_str +=
		"| leader_title               = " + orig_infobox_params["leader_title"] + "\n" +
		"| leader_name                    = " + (orig_infobox_params["leader_name"] ? orig_infobox_params["leader_name"] : "") + "\n";
	}
	for (var i = 1; i <= 3; i++) {
		if (orig_infobox_params["leader_title_" + i]) {
		new_infobox_str +=
		"| leader_title" + i + "           = " + orig_infobox_params["leader_title_" + i] + "\n" +
		"| leader_name" + i + "            = " + (orig_infobox_params["leader_name_" + i] ? orig_infobox_params["leader_name_" + i] : "") + "\n";
		}
	}

	new_infobox_str +=
		"| unit_pref               = Metric" + "\n" +
		"| area_footnotes          = " + (orig_infobox_params["area_total_cite"] ? orig_infobox_params["area_total_cite"] : "") + "\n" +
		/*
		"| area_urban_footnotes    = " + "\n" +
		"| area_rural_footnotes    = " + "\n" +
		"| area_metro_footnotes    = " + "\n" +
		"| area_magnitude          = " + "\n" +
		"| area_water_percent      = " + "\n" +
		*/
		"| area_rank               = " + (orig_infobox_params["area_rank"] ? orig_infobox_params["area_rank"] : "") + "\n" +
		"| area_total_km2          = " + (orig_infobox_params["area_total"] ? orig_infobox_params["area_total"] : "") + "\n" + //TODO: not necessarily km2 in the original
		/*
		"| area_land_km2           = " + "\n" +
		"| area_water_km2          = " + "\n" +
		"| area_urban_km2          = " + "\n" +
		"| area_rural_km2          = " + "\n" +
		"| area_metro_km2          = " + "\n" +
		"| dimensions_footnotes    = " + "\n" +
		*/
		"| elevation_footnotes     = " + (orig_infobox_params["altitude_cite"] ? orig_infobox_params["altitude_cite"] : "") + "\n" +
		"| elevation_m             = " + (orig_infobox_params["altitude"] ? orig_infobox_params["altitude"] : "") + "\n" + // TODO: not necessarily m in the original
		"| population_total        = " + (orig_infobox_params["population_total"] ? orig_infobox_params["population_total"] : "") + "\n" +
		"| population_as_of        = " + (orig_infobox_params["population_as_of"] ? orig_infobox_params["population_as_of"] : "") + "\n" +
		"| population_rank         = " + (orig_infobox_params["population_rank"] ? orig_infobox_params["population_rank"] : "") + "\n" +
		"| population_density_km2  = " + (orig_infobox_params["population_density"] ? orig_infobox_params["population_density"] : "auto") + "\n"; // TODO: not necessarily km2 in the original

	if (orig_infobox_params["population_metro"]) {
		new_infobox_str +=
		"| population_metro        = " + (orig_infobox_params["population_metro"] ? orig_infobox_params["population_metro"] : "") + "\n" +
		"| population_metro_footnotes = " + (orig_infobox_params["population_metro_cite"] ? orig_infobox_params["population_metro_cite"] : "") + "\n"
	}

	new_infobox_str +=
		"| population_demonym      = " + "\n" +
		"| population_note         = " + (orig_infobox_params["population_total_cite"] ? orig_infobox_params["population_total_cite"] : "auto") + "\n" +
		"| demographics_type1      = " + "Languages\n";

	var n_lang = 1; // number of languages
	for (var title in languages) {
		new_infobox_str += (
		"| demographics1_title" + n_lang + "    = " + title + "\n" +
		"| demographics1_info" + n_lang + "     = " + languages[title] + "\n"
		);
		n_lang++;
	}

	if (orig_infobox_params["ethnic_groups"]) {
		new_infobox_str +=
		"| demographics_type2      = " + "Ethnicity\n" +
		"| demographics2_title1    = " + "Ethnic groups\n" +
		"| demographics2_info1     = " + orig_infobox_params["ethnic_groups"] + "\n" +
		"| demographics2_title2    = " + "Year of data\n" +
		"| demographics2_info2     = " + (orig_infobox_params["ethnic_groups_year"] ? orig_infobox_params["ethnic_groups_year"] : "") + "\n";
	}

	new_infobox_str +=
		"| timezone1               = " + "[[Indian Standard Time|IST]]\n" +
		"| utc_offset1             = " + "+5:30\n" +
		"| postal_code_type        = " + (orig_infobox_params["postal_code"] ? "[[Postal Index Number|PIN]]" : "<!-- [[Postal Index Number|PIN]] -->") + "\n" +
		"| postal_code             = " + (orig_infobox_params["postal_code"] ? orig_infobox_params["postal_code"] : "") + "\n";

	if (orig_infobox_params["area_telephone"]) {
		new_infobox_str +=
		"| area_code_type          = " + "Telephone code\n" +
		"| area_code               = " + (orig_infobox_params["area_telephone"] ? orig_infobox_params["area_telephone"] : "") + "\n";
	}

	if (orig_infobox_params["abbreviation"]) {
		new_infobox_str +=
		"| iso_code                = " + (orig_infobox_params["abbreviation"] ? "[[ISO 3166-2:IN|" + orig_infobox_params["abbreviation"] + "]]" : "") + "\n";
	}

	new_infobox_str +=
		"| registration_plate      = " + (orig_infobox_params["vehicle_code_range"] ? orig_infobox_params["vehicle_code_range"] : "") + "\n";

	var n_other = 1; // number of other_info items
	for (var title in other_info) {
		new_infobox_str += (
		"| blank" + (n_other == 0 ? "": n_other) + "_name_sec1        = " + title + "\n" +
		"| blank" + (n_other == 0 ? "": n_other) + "_info_sec1        = " + other_info[title] + "\n"
		);
		n_other++;
	}

	var n_climate = 1; // number of climate items
	for (var title in climate) {
		new_infobox_str += (
		"| blank" + (n_climate == 0 ? "": n_climate) + "_name_sec2        = " + title + "\n" +
		"| blank" + (n_climate == 0 ? "": n_climate) + "_info_sec2        = " + climate[title] + "\n"
		);
		n_climate++;
	}

	new_infobox_str +=
		"| website                 = " + (orig_infobox_params["website"] ? ("{{URL|" + orig_infobox_params["website"] + "}}") : "") + "\n" +
		"| footnotes               = " + (orig_infobox_params["footnotes"] ? orig_infobox_params["footnotes"] : "") + "\n" +
		"}}";

	return new_infobox_str;
}


/**
 * Return the official language of the state/UT
 * @param the name of the state/UT
 * @return the official lanugage of the state, blank if no match found
 */
var getOfficialLanguage = function (state_name) {

	var languages = {
		"Andhra Pradesh" : "Telugu",
		"Arunachal Pradesh" : "English",
		"Assam" : "Assamese",
		"Bihar" : "Maithili, Hindi",
		"Chhattisgarh" : "Hindi, Chhattisgarhi",
		"Goa" : "Konkani",
		"Gujarat" : "Gujarati, Hindi",
		"Haryana" : "Hindi",
		"Himachal Pradesh" : "Hindi",
		"Jammu and Kashmir" : "Urdu",
		"Jammu & Kashmir" : "Urdu",
		"Jharkhand" : "Hindi, Santali",
		"Karnataka" : "Kannada",
		"Kerala" : "Malayalam, English",
		"Madhya Pradesh" : "Hindi",
		"Maharashtra" : "Marathi",
		"Manipur" : "Meiteilon (Manipuri)",
		"Meghalaya" : "English",
		"Mizoram" : "Mizo",
		"Nagaland" : "English",
		"Orissa" : "Oriya",
		"Odisha" : "Oriya",
		"Punjab" : "Punjabi",
		"Rajasthan" : "Hindi",
		"Sikkim" : "Nepali",
		"Tamil Nadu" : "Tamil",
		"Tripura" : "Bengali, Kokborok, English",
		"Uttarakhand" : "Hindi",
		"Uttar Pradesh" : "Hindi",
		"West Bengal" : "Bengali, English",
		"Andaman and Nicobar Islands" : "Hindi, English, Tamil",
		"Andaman and Nicobar" : "Hindi, English, Tamil",
		"Andaman & Nicobar Islands" : "Hindi, English, Tamil",
		"Andaman & Nicobar" : "Hindi, English, Tamil",
		"Chandigarh" : "Punjabi, Hindi, English",
		"Dadra and Nagar Haveli" : "Marathi, Gujarati",
		"Dadra & Nagar Haveli" : "Marathi, Gujarati",
		"Daman and Diu" : "Gujarati, English",
		"Daman & Diu" : "Gujarati, English",
		"Delhi" : "Hindi, English",
		"Lakshadweep" : "Malayalam",
		"Pondicherry" : "French, Tamil, English",
		"Puducherry" : "French, Tamil, English"
	};

	if (languages[state_name]) {
		return languages[state_name];
	}

	return "";
}


/**
 * initialize the program
 */
migrateIIJ.init = function() {
	// the infobox will automatically be migrated whenever the user clicks on "Edit this page"
	if (migrateIIJ.auto_replace == true) {
		// migrate the infobox
		if (wgAction == "edit") {
			migrateIIJ.migrateInfoboxIJ();
		}

		return;
	}

	// the user has to click on a portlet link to migrate the infobox
	var portletLink = mw.util.addPortletLink(
		"p-cactions",
		"#",
		"Infobox Indian Jurisdiction → settlement",
		"ca-infobox-settlement",
		"Click here to migrate the Infobox Indian Jurisdiction to Infobox settlement"
	);
	$(portletLink).click(function (e) {
		e.preventDefault();
		migrateIIJ.migrateInfoboxIJ();
	});
};

// bind to page load
addOnloadHook(migrateIIJ.init);