मीडियाविकि:Gadget-friendlytag.js

विकिपीडिया से

नोट: प्रकाशित करे के बाद, बदलाव देखे खातिर आपके अपने ब्राउजर के कैशे खाली करे के पड़ सकत बा।

  • फायरफॉक्स / सफारी:शिफ्ट दबा के रीलोड पर क्लिक करीं, या फिर Ctrl-F5 या Ctrl-R दबाईं (मैक पर ⌘-R)
  • गूगल क्रोम: Ctrl-Shift-R दबाईं (मैक पर ⌘-Shift-R)
  • इंटरनेट एक्स्प्लोरर/एज़: Ctrl दबा के Refresh पर क्लिक करीं, या Ctrl-F5 दबईं
  • ओपेरा: Menu → Settings में जाईं (मैक में Opera → Preferences) आ एकरे बाद Privacy & security → Clear browsing data → Cached images and files क्लिक करीं।
// <nowiki>

(function($) {


/*
 ****************************************
 *** friendlytag.js: Tag module
 ****************************************
 * Mode of invocation:     Tab ("Tag")
 * Active on:              Existing articles and drafts; file pages with a corresponding file
 *                         which is local (not on Commons); all redirects
 */

Twinkle.tag = function friendlytag() {
	// redirect tagging
	if (Morebits.wiki.isPageRedirect()) {
		Twinkle.tag.mode = 'redirect';
		Twinkle.addPortletLink(Twinkle.tag.callback, 'टैग जोड़ीं', 'friendly-tag', 'अनुप्रेषण टैग');
	// file tagging
	} else if (mw.config.get('wgNamespaceNumber') === 6 && !document.getElementById('mw-sharedupload') && document.getElementById('mw-imagepage-section-filehistory')) {
		Twinkle.tag.mode = 'file';
		Twinkle.addPortletLink(Twinkle.tag.callback, 'टैग जोड़ीं', 'friendly-tag', 'फाइल पर रखरखाव टैग जोड़ीं');
	// article/draft article tagging
	} else if ([0, 118].indexOf(mw.config.get('wgNamespaceNumber')) !== -1 && mw.config.get('wgCurRevisionId')) {
		Twinkle.tag.mode = 'article';
		// Can't remove tags when not viewing current version
		Twinkle.tag.canRemove = (mw.config.get('wgCurRevisionId') === mw.config.get('wgRevisionId')) &&
			// Disabled on latest diff because the diff slider could be used to slide
			// away from the latest diff without causing the script to reload
			!mw.config.get('wgDiffNewId');
		Twinkle.addPortletLink(Twinkle.tag.callback, 'टैग जोड़ीं', 'friendly-tag', 'लेख में टैग जोड़ीं भा हटाईं');
	}
};

Twinkle.tag.checkedTags = [];

Twinkle.tag.callback = function friendlytagCallback() {
	var Window = new Morebits.simpleWindow(630, Twinkle.tag.mode === 'article' ? 500 : 400);
	Window.setScriptName('ट्विंकल');
	// anyone got a good policy/guideline/info page/instructional page link??
	Window.addFooterLink('ट्विंकल मदद', 'WP:TW/DOC#tag');

	var form = new Morebits.quickForm(Twinkle.tag.callback.evaluate);

	form.append({
		type: 'input',
		label: 'तुरंता खोज: ',
		name: 'quickfilter',
		size: '30px',
		event: function twinkletagquickfilter() {
			// flush the DOM of all existing underline spans
			$allCheckboxDivs.find('.search-hit').each(function(i, e) {
				var label_element = e.parentElement;
				// This would convert <label>Hello <span class=search-hit>wo</span>rld</label>
				// to <label>Hello world</label>
				label_element.innerHTML = label_element.textContent;
			});

			if (this.value) {
				$allCheckboxDivs.hide();
				$allHeaders.hide();
				var searchString = this.value;
				var searchRegex = new RegExp(mw.util.escapeRegExp(searchString), 'i');

				$allCheckboxDivs.find('label').each(function () {
					var label_text = this.textContent;
					var searchHit = searchRegex.exec(label_text);
					if (searchHit) {
						var range = document.createRange();
						var textnode = this.childNodes[0];
						range.selectNodeContents(textnode);
						range.setStart(textnode, searchHit.index);
						range.setEnd(textnode, searchHit.index + searchString.length);
						var underline_span = $('<span>').addClass('search-hit').css('text-decoration', 'underline')[0];
						range.surroundContents(underline_span);
						this.parentElement.style.display = 'block'; // show
					}
				});
			} else {
				$allCheckboxDivs.show();
				$allHeaders.show();
			}
		}
	});

	switch (Twinkle.tag.mode) {
		case 'article':
			Window.setTitle('लेख रखरखाव टैगिंग');

			form.append({
				type: 'select',
				name: 'sortorder',
				label: 'लिस्ट के देखे के तरीका:',
				tooltip: 'एकरा के आप अपने ट्विंकल पसंदसेटिंग [[WP:TWPREFS]] में जा के बदल सकत बानी कि हर बेरी डिफाल्ट में आपके केङने देखावल जाय। ',
				event: Twinkle.tag.updateSortOrder,
				list: [
					{ type: 'option', value: 'cat', label: 'समस्या के हिसाब से बाँट के', selected: Twinkle.getPref('tagArticleSortOrder') === 'cat' },
					{ type: 'option', value: 'alphaBh', label: 'भोजपुरी अच्छर के हिसाब से', selected: Twinkle.getPref('tagArticleSortOrder') === 'alphaBh' },
					{ type: 'option', value: 'alpha', label: 'अंगरेजी अच्छर के हिसाब से', selected: Twinkle.getPref('tagArticleSortOrder') === 'alpha' }
				]
			});


			if (!Twinkle.tag.canRemove) {
				var divElement = document.createElement('div');
				divElement.innerHTML = 'पहिले से मौजूद टैग हटावे खातिर लेख के वर्तमान रिवीजन पर जा के टैग मेनू खोलीं';
				form.append({
					type: 'div',
					name: 'untagnotice',
					label: divElement
				});
			}

			form.append({
				type: 'div',
				id: 'tagWorkArea',
				className: 'morebits-scrollbox',
				style: 'max-height: 28em'
			});

			form.append({
				type: 'checkbox',
				list: [
					{
						label: 'अगर संभव होखे तब टैग सभ के {{multiple issues}} में एकट्ठा रखल जाय',
						value: 'group',
						name: 'group',
						tooltip: 'अगर दू गो भा बेसी टैग जोड़ल जा रहल होखे आ ऊ {{multiple issues}} में जोड़े खातिर उचित होखें, अगर ई बक्सा चेक रही तब उनहन के एकट्ठा क के {{multiple issues}} टेम्पलेट में लगा के रखल जाई।',
						checked: Twinkle.getPref('groupByDefault')
					}
				]
			}
			);

			break;

		case 'file':
			Window.setTitle('फाइल रखरखाव टैगिंग');

			form.append({ type: 'header', label: 'लाइसेंस आ स्रोत समस्या टैग' });
			form.append({ type: 'checkbox', name: 'fileTags', list: Twinkle.tag.file.licenseList });

			form.append({ type: 'header', label: 'विकिमीडिया कॉमंस संबंधी टैग' });
			form.append({ type: 'checkbox', name: 'fileTags', list: Twinkle.tag.file.commonsList });

			form.append({ type: 'header', label: 'सफाई टैग' });
			form.append({ type: 'checkbox', name: 'fileTags', list: Twinkle.tag.file.cleanupList });

			form.append({ type: 'header', label: 'फोटो के क्वालिटी संबंधी टैग' });
			form.append({ type: 'checkbox', name: 'fileTags', list: Twinkle.tag.file.qualityList });

			form.append({ type: 'header', label: 'रिप्लेसमेंट टैग' });
			form.append({ type: 'checkbox', name: 'fileTags', list: Twinkle.tag.file.replacementList });

			if (Twinkle.getPref('customFileTagList').length) {
				form.append({ type: 'header', label: 'Custom tags' });
				form.append({ type: 'checkbox', name: 'fileTags', list: Twinkle.getPref('customFileTagList') });
			}
			break;

		case 'redirect':
			Window.setTitle('अनुप्रेषण टैगिंग');

			form.append({ type: 'header', label: 'इस्पेलिंग आ काल (व्याकरण) इत्यादि संबंधी टैगिंग' });
			form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.spellingList });

			form.append({ type: 'header', label: 'दूसर नाँव संबंधी टैगिंग' });
			form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.alternativeList });

			form.append({ type: 'header', label: 'बिबिध आ प्रबंधकीय काम संबंधी टेम्पलेट' });
			form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.tag.administrativeList });

			if (Twinkle.getPref('customRedirectTagList').length) {
				form.append({ type: 'header', label: 'आपन बनावल टैग' });
				form.append({ type: 'checkbox', name: 'redirectTags', list: Twinkle.getPref('customRedirectTagList') });
			}
			break;

		default:
			alert('Twinkle.tag: unknown mode ' + Twinkle.tag.mode);
			break;
	}

	if (document.getElementsByClassName('patrollink').length) {
		form.append({
			type: 'checkbox',
			list: [
				{
					label: 'एह पन्ना के जाँचल चिन्हित करीं',
					value: 'patrolPage',
					name: 'patrolPage',
					checked: Twinkle.getPref('markTaggedPagesAsPatrolled')
				}
			]
		});
	}
	form.append({ type: 'submit' });

	var result = form.render();
	Window.setContent(result);
	Window.display();

	// for quick filter:
	$allCheckboxDivs = $(result).find('[name$=Tags]').parent();
	$allHeaders = $(result).find('h5');
	result.quickfilter.focus();  // place cursor in the quick filter field as soon as window is opened
	result.quickfilter.autocomplete = 'off'; // disable browser suggestions
	result.quickfilter.addEventListener('keypress', function(e) {
		if (e.keyCode === 13) { // prevent enter key from accidentally submitting the form
			e.preventDefault();
			return false;
		}
	});

	if (Twinkle.tag.mode === 'article') {

		Twinkle.tag.alreadyPresentTags = [];

		if (Twinkle.tag.canRemove) {
			// Look for existing maintenance tags in the lead section and put them in array

			// All tags are HTML table elements that are direct children of .mw-parser-output,
			// except when they are within {{multiple issues}}
			$('.mw-parser-output').children().each(function parsehtml(i, e) {

				// break out on encountering the first heading, which means we are no
				// longer in the lead section
				if (e.tagName === 'H2') {
					return false;
				}

				// The ability to remove tags depends on the template's {{ambox}} |name=
				// parameter bearing the template's correct name (preferably) or a name that at
				// least redirects to the actual name

				// All tags have their first class name as "box-" + template name
				if (e.className.indexOf('box-') === 0) {
					if (e.classList[0] === 'box-Multiple_issues') {
						$(e).find('.ambox').each(function(idx, e) {
							var tag = e.classList[0].slice(4).replace(/_/g, ' ');
							Twinkle.tag.alreadyPresentTags.push(tag);
						});
						return true; // continue
					}

					var tag = e.classList[0].slice(4).replace(/_/g, ' ');
					Twinkle.tag.alreadyPresentTags.push(tag);
				}
			});

			// {{Uncategorized}} and {{Improve categories}} are usually placed at the end
			if ($('.box-Uncategorized').length) {
				Twinkle.tag.alreadyPresentTags.push('Uncategorized');
			}
			if ($('.box-Improve_categories').length) {
				Twinkle.tag.alreadyPresentTags.push('Improve categories');
			}

		}

		// Add status text node after Submit button
		var statusNode = document.createElement('small');
		statusNode.id = 'tw-tag-status';
		Twinkle.tag.status = {
			// initial state; defined like this because these need to be available for reference
			// in the click event handler
			numAdded: 0,
			numRemoved: 0
		};
		$(Window.buttons[0]).after(statusNode);

		// fake a change event on the sort dropdown, to initialize the tag list
		var evt = document.createEvent('Event');
		evt.initEvent('change', true, true);
		result.sortorder.dispatchEvent(evt);

	} else {
		// Redirects and files: Add a link to each template's description page
		Morebits.quickForm.getElements(result, Twinkle.tag.mode + 'टैग').forEach(generateLinks);
	}
};


// $allCheckboxDivs and $allHeaders are defined globally, rather than in the
// quickfilter event function, to avoid having to recompute them on every keydown
var $allCheckboxDivs, $allHeaders;

Twinkle.tag.updateSortOrder = function(e) {
	var form = e.target.form;
	var sortorder = e.target.value;
	Twinkle.tag.checkedTags = form.getChecked('articleTags') || [];

	var container = new Morebits.quickForm.element({ type: 'fragment' });

	// function to generate a checkbox, with appropriate subgroup if needed
	var makeCheckbox = function(tag, description) {
		var checkbox = { value: tag, label: '{{' + tag + '}}: ' + description };
		if (Twinkle.tag.checkedTags.indexOf(tag) !== -1) {
			checkbox.checked = true;
		}
		switch (tag) {
			case 'Cleanup':
				checkbox.subgroup = {
					name: 'cleanup',
					type: 'input',
					label: 'सफाई के कारन: ',
					tooltip: 'दिहल जरूरी बा।',
					size: 35
				};
				break;
			case 'Close paraphrasing':
				checkbox.subgroup = {
					name: 'closeParaphrasing',
					type: 'input',
					label: 'स्रोत: ',
					tooltip: 'ऊ जगह जहाँ से पैराफ्रेजिंग कइल गइल बा।'
				};
				break;
			case 'Copy edit':
				checkbox.subgroup = {
					name: 'copyEdit',
					type: 'input',
					label: '"... खातिर एह लेख के कॉपीएडिटिंग के जरूरत हो सके ला।" ',
					tooltip: 'उदाहरण: "इस्पेलिंग एकरूपता"। ई दिहल राउर मर्जी पर बा।',
					size: 35
				};
				break;
			case 'Copypaste':
				checkbox.subgroup = {
					name: 'copypaste',
					type: 'input',
					label: 'सोर्स यूआरएल: ',
					tooltip: 'अगर मालुम होखे।',
					size: 50
				};
				break;
			case 'Expand language':
				checkbox.subgroup = [ {
					name: 'expandLanguageLangCode',
					type: 'input',
					label: 'भाषा के कोड: ',
					tooltip: 'ओह भाषा के कोड जवना के विकिपीडिया के आधार पर लेख बढ़ावल जा सकत बा।'
				}, {
					name: 'expandLanguageArticle',
					type: 'input',
					label: 'लेख के नाँव: ',
					tooltip: 'दुसरी विकिपीडिया पर लेख के नाँव, बिना इंटरविकि प्रीफिक्स के।'
				}
				];
				break;
			case 'Expert needed':
				checkbox.subgroup = [
					{
						name: 'expertNeeded',
						type: 'input',
						label: 'संबंधित विकिप्रोजेक्ट के नाँव: ',
						tooltip: 'राउर मर्जी बा। मन करे तब अइसन विकिप्रोजेक्ट के नाँव बता दीं; "विकिप्रोजेक्ट" शब्द पहिले जोड़े के जरूरत ना बाटे।'
					},
					{
						name: 'expertNeededReason',
						type: 'input',
						label: 'कारण: ',
						tooltip: 'संछेप में कारण बताईं या बातचीत के कड़ी देईं।'
					},
					{
						name: 'expertNeededTalk',
						type: 'input',
						label: 'बातचीत कड़ी: ',
						tooltip: 'लेख के बातचीत पन्ना के ऊ खंड जहाँ चर्चा बाटे। कड़ी मत दीं, बस खंड के नाँव लिख दीं। ई पैरामीटर या फिर ऊपर वाला में कारण बतावल जरूरी बाटे।'
					}
				];
				break;
			case 'Globalize':
				checkbox.subgroup = {
					name: 'globalizeRegion',
					type: 'input',
					label: 'देस चाहे क्षेत्र जेकरा बेसी महत्व दिहल गइल बा'
				};
				break;
			case 'History merge':
				checkbox.subgroup = [
					{
						name: 'histmergeOriginalPage',
						type: 'input',
						label: 'दूसर लेख: ',
						tooltip: 'लेख के नाँव जवना के इतिहास विलय इहाँ कइल जाई (जरूरी बा)।'
					},
					{
						name: 'histmergeReason',
						type: 'input',
						label: 'कारण: ',
						tooltip: 'संछेप में इतिहास विलय के कारन बताईं। ई "काहें से कि" से शुरू होखे के चाहीं आ पूर्ण बिराम पर खतम होखे के चाहीं।'
					},
					{
						name: 'histmergeSysopDetails',
						type: 'input',
						label: 'एक्स्ट्रा जानकारी: ',
						tooltip: 'बहुत जटिल केस खातिर अउरी जानकारी आ सुझाव लिखीं जेकरा प्रबंधक लोग धियान में रखी।'
					}
				];
				break;
			case 'Merge':
			case 'Merge from':
			case 'Merge to':
				var otherTagName = 'Merge';
				switch (tag) {
					case 'Merge from':
						otherTagName = 'Merge to';
						break;
					case 'Merge to':
						otherTagName = 'Merge from';
						break;
					// no default
				}
				checkbox.subgroup = [
					{
						name: 'mergeTarget',
						type: 'input',
						label: 'दूसर लेख(सभ): ',
						tooltip: 'अगर एगो से बेसी लेख बतावल जा रहल होखे, उनहन के नाँव पाइप कैरेक्टर से अलगा क के लिखीं।'
					},
					{
						name: 'mergeTagOther',
						type: 'checkbox',
						list: [
							{
								label: 'दुसरे लेख पर {{' + otherTagName + '}} टैग जोड़ल जाय',
								checked: true,
								tooltip: 'तब्बे काम करी जब एकही दूसर लेख दिहल गइल होखे।'
							}
						]
					}
				];
				if (mw.config.get('wgNamespaceNumber') === 0) {
					checkbox.subgroup.push({
						name: 'mergeReason',
						type: 'textarea',
						label: 'विलय के कारण (एकरा के ' +
							(tag === 'Merge to' ? 'दुसरे लेख' : 'एह लेख') + ' के बातचीत पन्ना पर पोस्ट कइल जाई):',
						tooltip: 'राउर मर्जी बा,बाकी बहुत मजबूती से इहे सलाह बा कि ई कारन जोड़ल जाय।'
					});
				}
				break;
			case 'Not Bhojpuri':
			case 'Rough translation':
				checkbox.subgroup = [
					{
						name: 'translationLanguage',
						type: 'input',
						label: 'लेख के भाषा: ',
						tooltip: 'अगर लेख के भाषा न बुझात होखे, पहिले [[वि:चौपाल]] पर पूछ लीं।'
					}
				];
				if (tag === 'Not Bhojpuri') {
					checkbox.subgroup.push({
						name: 'translationNotify',
						type: 'checkbox',
						list: [
							{
								label: 'लेख बनावे वाला के सूचना भेजीं',
								checked: true,
								tooltip: "ई बनावे वाला के वार्ता पन्ना पर {{uw-notbhojpuri}} के टैग से सूचना जोड़ दी।"
							}
						]
					});
				}
				if (mw.config.get('wgNamespaceNumber') === 0) {
					checkbox.subgroup.push({
						name: 'translationPostAtPNT',
						type: 'checkbox',
						list: [
							{
								label: 'विकिपीडिया:अनुबाद अनुरोध पर लिस्ट में जोड़ीं',
								checked: true
							}
						]
					});
					checkbox.subgroup.push({
						name: 'translationComments',
						type: 'textarea',
						label: 'अनुरोध पन्ना खातिर अउरी कौनों टिप्पणी',
						tooltip: 'राउर मर्जी बा, हो सके त लिखीं'
					});
				}
				break;
			case 'Notability':
				checkbox.subgroup = {
					name: 'notability',
					type: 'select',
					list: [
						{ label: "{{notability}}: विकिपीडिया के आम नोटबिलिटी दिसानिर्देस अनुसार ना होखे तब", value: 'none' },
						//{ label: '{{notability|Academics}}: notability guideline for academics', value: 'Academics' },
						{ label: '{{notability|Biographies}}: जीवनी खातिर नोटबिलिटी दिसनिर्देस अनुसार ना', value: 'Biographies' },
						//{ label: '{{notability|Books}}: notability guideline for books', value: 'Books' },
						//{ label: '{{notability|Companies}}: notability guidelines for companies and organizations', value: 'Companies' },
						//{ label: '{{notability|Events}}: notability guideline for events', value: 'Events' },
						//{ label: '{{notability|Films}}: notability guideline for films', value: 'Films' },
						//{ label: '{{notability|Places}}: notability guideline for places', value: 'Places' },
						//{ label: '{{notability|Music}}: notability guideline for music', value: 'Music' },
						//{ label: '{{notability|Neologisms}}: notability guideline for neologisms', value: 'Neologisms' },
						//{ label: '{{notability|Numbers}}: notability guideline for numbers', value: 'Numbers' },
						//{ label: '{{notability|Products}}: notability guideline for products and services', value: 'Products' },
						//{ label: '{{notability|Sport}}: notability guideline for sports and athletics', value: 'Sport' },
						//{ label: '{{notability|Television}}: notability guideline for television shows', value: 'Television' },
						//{ label: '{{notability|Web}}: notability guideline for web content', value: 'Web' }
					]
				};
				break;
			default:
				break;
		}
		return checkbox;
	};

	var makeCheckboxesForAlreadyPresentTags = function() {
		container.append({ type: 'header', id: 'tagHeader0', label: 'पहिले से मौजूद टैग' });
		var subdiv = container.append({ type: 'div', id: 'tagSubdiv0' });
		var checkboxes = [];
		var unCheckedTags = e.target.form.getUnchecked('alreadyPresentArticleTags') || [];
		Twinkle.tag.alreadyPresentTags.forEach(function(tag) {
			var description = Twinkle.tag.article.tags[tag];
			var checkbox =
				{
					value: tag,
					label: '{{' + tag + '}}' + (description ? ': ' + description : ''),
					checked: unCheckedTags.indexOf(tag) === -1
					// , subgroup: { type: 'input', name: 'removeReason', label: 'Reason', tooltip: 'Enter reason for removing this tag' }
					// TODO: add option for providing reason for removal
				};

			checkboxes.push(checkbox);
		});
		subdiv.append({
			type: 'checkbox',
			name: 'alreadyPresentArticleTags',
			list: checkboxes
		});
	};

	if (sortorder === 'cat') { // categorical sort order
		// function to iterate through the tags and create a checkbox for each one
		var doCategoryCheckboxes = function(subdiv, array) {
			var checkboxes = [];
			$.each(array, function(k, tag) {
				var description = Twinkle.tag.article.tags[tag];
				if (Twinkle.tag.alreadyPresentTags.indexOf(tag) === -1) {
					checkboxes.push(makeCheckbox(tag, description));
				}
			});
			subdiv.append({
				type: 'checkbox',
				name: 'articleTags',
				list: checkboxes
			});
		};

		if (Twinkle.tag.alreadyPresentTags.length > 0) {
			makeCheckboxesForAlreadyPresentTags();
		}
		var i = 1;
		// go through each category and sub-category and append lists of checkboxes
		$.each(Twinkle.tag.article.tagCategories, function(title, content) {
			container.append({ type: 'header', id: 'tagHeader' + i, label: title });
			var subdiv = container.append({ type: 'div', id: 'tagSubdiv' + i++ });
			if (Array.isArray(content)) {
				doCategoryCheckboxes(subdiv, content);
			} else {
				$.each(content, function(subtitle, subcontent) {
					subdiv.append({ type: 'div', label: [ Morebits.htmlNode('b', subtitle) ] });
					doCategoryCheckboxes(subdiv, subcontent);
				});
			}
		});
	} else if (sortorder === 'alphaBh') { // for Bhojpuri order
		// function to iterate through the tags and create a checkbox for each one
		var doCategoryCheckboxes = function(subdiv, array) {
			var checkboxes = [];
			$.each(array, function(k, tag) {
				var description = Twinkle.tag.article.tags[tag];
				if (Twinkle.tag.alreadyPresentTags.indexOf(tag) === -1) {
					checkboxes.push(makeCheckbox(tag, description));
				}
			});
			subdiv.append({
				type: 'checkbox',
				name: 'articleTags',
				list: checkboxes
			});
		};

		if (Twinkle.tag.alreadyPresentTags.length > 0) {
			makeCheckboxesForAlreadyPresentTags();
		}
		var i = 1;
		// go through each category append lists of checkboxes
		$.each(Twinkle.tag.article.tagBhojpuri, function(title, content) {
			container.append({ type: 'header', id: 'tagHeader' + i, label: title });
			var subdiv = container.append({ type: 'div', id: 'tagSubdiv' + i++ });
			if (Array.isArray(content)) {
				doCategoryCheckboxes(subdiv, content);
			} else {
				$.each(content, function(subtitle, subcontent) {
					subdiv.append({ type: 'div', label: [ Morebits.htmlNode('b', subtitle) ] });
					doCategoryCheckboxes(subdiv, subcontent);
				});
			}
		});
	} else { // alphabetical sort order
		if (Twinkle.tag.alreadyPresentTags.length > 0) {
			makeCheckboxesForAlreadyPresentTags();
			container.append({ type: 'header', id: 'tagHeader1', label: 'Available tags' });
		}
		var checkboxes = [];
		$.each(Twinkle.tag.article.tags, function(tag, description) {
			if (Twinkle.tag.alreadyPresentTags.indexOf(tag) === -1) {
				checkboxes.push(makeCheckbox(tag, description));
			}
		});
		container.append({
			type: 'checkbox',
			name: 'articleTags',
			list: checkboxes
		});
	}

	// append any custom tags
	if (Twinkle.getPref('customTagList').length) {
		container.append({ type: 'header', label: 'Custom tags' });
		container.append({ type: 'checkbox', name: 'articleTags',
			list: Twinkle.getPref('customTagList').map(function(el) {
				el.checked = Twinkle.tag.checkedTags.indexOf(el.value) !== -1;
				return el;
			})
		});
	}

	var $workarea = $(form).find('#tagWorkArea');
	var rendered = container.render();
	$workarea.empty().append(rendered);

	// for quick filter:
	$allCheckboxDivs = $workarea.find('[name$=Tags]').parent();
	$allHeaders = $workarea.find('h5, .quickformDescription');
	form.quickfilter.value = ''; // clear search, because the search results are not preserved over mode change
	form.quickfilter.focus();

	// style adjustments
	$workarea.find('h5').css({ 'font-size': '110%' });
	$workarea.find('h5:not(:first-child)').css({ 'margin-top': '1em' });
	$workarea.find('div').filter(':has(span.quickformDescription)').css({ 'margin-top': '0.4em' });

	var alreadyPresentTags = Morebits.quickForm.getElements(form, 'alreadyPresentArticleTags');
	if (alreadyPresentTags) {
		alreadyPresentTags.forEach(generateLinks);
	}
	// in the unlikely case that *every* tag is already on the page
	var notPresentTags = Morebits.quickForm.getElements(form, 'articleTags');
	if (notPresentTags) {
		notPresentTags.forEach(generateLinks);
	}

	// tally tags added/removed, update statusNode text
	var statusNode = document.getElementById('tw-tag-status');
	$('[name=articleTags], [name=alreadyPresentArticleTags]').click(function() {
		if (this.name === 'articleTags') {
			Twinkle.tag.status.numAdded += this.checked ? 1 : -1;
		} else if (this.name === 'alreadyPresentArticleTags') {
			Twinkle.tag.status.numRemoved += this.checked ? -1 : 1;
		}

		var firstPart = Twinkle.tag.status.numAdded + ' टैग' + (Twinkle.tag.status.numAdded > 1 ? ' जोड़ल जा रहल बाड़ें' : ' जोड़ल जाता');
		var secondPart = Twinkle.tag.status.numRemoved + ' टैग' + (Twinkle.tag.status.numRemoved > 1 ? ' हटावल जात बाड़ें' : ' हटावल जाता');
		statusNode.textContent =
			(Twinkle.tag.status.numAdded ? '  ' + firstPart : '') +
			(Twinkle.tag.status.numRemoved ? (Twinkle.tag.status.numAdded ? '; ' : '  ') + secondPart : '');
	});
};

/**
 * Adds a link to each template's description page
 * @param {Morebits.quickForm.element} checkbox  associated with the template
 */
var generateLinks = function(checkbox) {
	var link = Morebits.htmlNode('a', '>');
	link.setAttribute('class', 'tag-template-link');
	var tagname = checkbox.values;
	link.setAttribute('href', mw.util.getUrl(
		(tagname.indexOf(':') === -1 ? 'टेम्पलेट:' : '') +
		(tagname.indexOf('|') === -1 ? tagname : tagname.slice(0, tagname.indexOf('|')))
	));
	link.setAttribute('target', '_blank');
	$(checkbox).parent().append(['\u00A0', link]);
};


// Tags for ARTICLES start here

Twinkle.tag.article = {};

// A list of all article tags, in alphabetical order
// To ensure tags appear in the default "categorized" view, add them to the tagCategories hash below.

Twinkle.tag.article.tags = {
	'Advert': '{{परचार}}: लेख परचार नियर लिखल गइल बा',
	'All plot': '{{कहानी}}: पुरा लेखवे कौनों कहानी के संछेप नियर लिखल बा',
	'Autobiography': '{{आत्मकथा}}: आत्मकथा नियर बा, हो सकेला कि नजरिया तटस्थ ना होखे',
	'BLP sources': '{{जीवनी स्रोत}}: जिंदा ब्यक्ति के जीवनी में अउरी स्रोत के संदर्भ चाहत बा',
	'BLP unsourced': '{{जीवनी बिना स्रोत}}: जिंदा ब्यक्ति के जीवनी में एकहू स्रोत के संदर्भ ना बा',
	'Citation style': '{{हवाला इस्टाइल}}: लेख में दिहल संदर्भ के हवाला कई किसिम के इस्टाइल में बा',
	'Cleanup': '{{सफाई}}: लेख में सफाई करे के जरूरत बा',
	'Cleanup bare URLs': '{{सफाई यूआरएल संदर्भ}}: खाली यूआरएल कड़ी के संदर्भ बा, बिस्तार कइल जाय',
	'Cleanup-PR': '{{सफाई पीआर}}: प्रेस रिलीज भा अखबारी इस्टाइल में लिखल बा',
	'Cleanup reorganize': '{{सफाई ब्यवस्थित}}: लेख के दोबारा बेवस्थित ढंग से लिखल चाहत बा',
	'Cleanup rewrite': '{{सफाई दोबारा}}: लेख के विकिपीडिया नीति आ गाइड के हिसाब से दोबारा लिखे के जरूरत बा',
	'Cleanup tense': '{{सफाई काल}}: कुछ बात भूतकाल में बा कुछ वर्तमान काल में, ब्याकरण सही कइल चाहत बा',
	'Close paraphrasing': '{{पैराफ्रेजिंग}}: गैर-फ्री भा कॉपीराइट वाला जगह के पाठ के नकल मामूली हेरफेर के साथ',
	'COI': '{{निजी इंट्रेस्ट}}: लेख के लेखक के बिसय से निजी जुड़ाव हो सके ला',
	'Condense': '{{कंडेंस}}: बहुत बेसी खंड में बाँटल बा, एकट्ठा क के लिखे के जरूरत बा',
	'Confusing': '{{कन्फ्यूजन}}: लेख बहुत भरमाव आ कन्फ्यूजन वाला बा, बात साफ नइखे होखत',
	'Context': '{{प्रसंग}}: जे बिसय से अनजान बा ओकरा खाती लेख में कुछ अउरी प्रसंग चाहत बा कि लेख बुझा सके',
	'Copy edit': '{{कॉपी एडिट}}: लेख के कॉपीएडिटिंग के जरूरत बाटे, ब्याकरण, इस्पेलिंग, लहजा इत्यादि के सुधार खाती',
	'Copypaste': '{{कॉपी पेस्ट}}: बुझाता कि कौनों दुसरे जगह से कॉपी-पेस्ट कइल गइल बा',
	'Current': '{{हाल के घटना}}: हाल में भइल भा वर्तमान में जारी घटना के बर्णन करे वाला लेख',
	'Dead end': '{{अंतिम माथ}}: लेख में कौनों दुसरे लेख के विकिकड़ी नइखे, अंतिम छोर जहाँ से दुसरे लेख में जाइल मुश्किल बा',
	'Disputed': '{{बिबादित}}: लेख में दिहल जानकारी के फैक्ट अनुसार होखे पर बिबाद बा',
	'Essay-like': '{{निबंध}}: ब्यक्तिगत सोच, राय भा तर्क-बितर्क के साथ निबंध नियर लिखल गइल बा',
	'Expand language': '{{भाषा बिस्तार}}: कौनों दूसर विकि (हिंदी-अंग्रेजी छोड़ के) के लेख अनुसार बढ़ावे लायक',
	'Expert needed': '{{बिसेसज्ञ}}: बिसय के बिसेसग्य के धियान चाहत बा',
	'External links': '{{बाहरी कड़ी}}: लेख में दिहल बाहरी कड़ी विकिपीडिया के दिसानिर्देस अनुसार ना बाटे',
	'Fanpov': '{{प्रशंसक}}: केहू फैन-फालोवर के नजरिया से लिखल गइल बा',
	'Fiction': '{{कथाकहानी}}: लेख वास्तविक दुनिया के चीज आ कथाकहानी में अंतर नइखे क पावत',
	'Globalize': '{{बैस्विक}}: लेख के बैस्विक नजरिया से लिखे के जरूरत बा, ई कौनों देस भा इलाका के हिसाब से लिखल बा',
	'History merge': '{{इतिहास विलय}}: कौनो लेख के मय इतिहास एह लेख में मेरवन कइल चाहत बा',
	'Hoax': '{{धोखा}}: कुछ हिस्सा भा पूरा धोखा (होक्स) हो सके ला',
	'Improve categories': '{{अउरी श्रेणी}}: लेख में अउरी श्रेणी जोड़ल चाहत बा चाहे सटीक श्रेणी जोड़े के जरूरत',
	'Incomprehensible': '{{अबूझ}}: लगभग अबूझ भा बूझे में बहुत मुश्किल बा',
	'In-universe': '{{कथा-वास्तविक}}: कथा कहानी के चीज अइसन प्रस्तुत कइल बा जइसे कि ऊ असली दुनिया के चीज होखे',
	'In use': '{{इस्तेमाल में}}: लेख में बड़हन बदलाव हो रहल बा आ कुछ समय खाती संपादन से बचे के चाहत बा',
	'Lead missing': '{{भूमिका नइखे}}: लेख में भूमिका ना बाटे',
	'Lead rewrite': '{{भूमिका दोबारा लिखीं}}: भूमिका के विकिपीडिया दिसानिर्देश अनुसार दोबारा लिखल चाहत बा',
	'Lead too long': '{{भूमिका लमहर}}: भूमिका बेमतलब बहुत लमहर बा, लेख के लंबाई के हिसाब से रखल जाय',
	'Lead too short': '{{भूमिका छोट}}: लेख के भूमिका के बढ़ावल जाय कि सगरी मुख्य जानकारी के संछेप इहाँ आ जाय',
	'Long plot': '{{कथासारांश लमहर}}: कथा-कहानी के सारांश बहुत लमहर बा',
	'Manual': '{{गाइड नियर}}: कौनों गाइड भा मैनुअल नियर लिखल बाटे',
	'Merge': '{{विलय}}: लेख दुसरे बतावल लेख के साथे विलय (मिला दिहल) के जरूरत बा',
	'Merge from': '{{से विलय}}: कौनों दुसरा लेख से सामग्री ले आ के इहाँ विलय कइल चाहत बा',
	'Merge to': '{{में विलय}}: एह लेख के सामग्री कौनों दुसरे लेख में ले जा के विलय कइल चाहत बा',
	'More citations needed': '{{अउरी हवाला}}: लिखल गइल बातन के सत्यापन खातिर अउरी संदर्भ भा स्रोत के जरूरत बा',
	'More footnotes': '{{अउरी फुटनोट}}: लेख में मौजूद संदर्भ सभ के इनलाइन हवाला अउरी चाहत बा',
	'No footnotes': '{{फुटनोट नइखे}}: लेख में संदर्भ बा बाकी फुटनोट जनरेट करे खातिर इनलाइन हवाला नइखे दिहल गइल',
	'No plot': '{{कथासारांश नइखे}}: लेख में दिहल कहानी के सारांश नइखे',
	'Non-free': '{{गैर-फ्री}}: बहुत बेसी भा अनुचित इस्तेमाल अइसन सामग्री के बा जे कॉपीराइट वाली हो सके ले',
	'Notability': '{{उल्लेख जोग ना}}: लेख के बिसय उल्लेख जोग (नोटेबल) ना होखे के संभावना बा',
	'Not Bhojpuri': '{{भोजपुरी नइखे}}: भोजपुरी के अलावा दुसरा कौनों भाषा में लिखल बा जेकरे अनुबाद के जरूरत बा',
	'One source': '{{एक्के स्रोत}}: मुख्य रूप से एकही स्रोतके आधार बना के लिखल बाटे',
	'Original research': '{{मूल रिसर्च}}: लेख में मूल रिसर्च बाटे, जानकारी के आधार पर सीधे इहँवे निष्कर्ष निकालल गइल बा',
	'Orphan': '{{अनाथ}}: लेख के विकिकड़ी कौनों अउरी लेख में ना जुड़ल बा जहाँ से केहू इहाँ पहुँच सके',
	'Overlinked': '{{बहुत कड़ी}}: लेख में बेमतलब दुसरे लेखन के कड़ी बा, कड़ी के दोहराव बा',
	'Overly detailed': '{{बहुत डिटेल}}: बहुत बेसी डिटेल में बिबरन बा जे एकरा के समझे में परेशानी क सके ला',
	'Over-quotation': '{{बहुत कोटेशन}}: लेख में बेसी भा बहुत लमहर कोटेशन बाड़ीं, अइसन जरूरत ज्ञानकोश में ना बा',
	'Peacock': '{{सजावटी}}: सजावटी शब्दन के इस्तेमाल से बिसय के परचार, परमोशन हो रहल बा; जानकारी परक बनावल जाय',
	'POV': '{{नजरिया}}: लेख तटस्थ नजरिया से ना लिखल गइल बा',
	'Primary sources': '{{प्राथमिक स्रोत}}: प्राथमिक, मने कि मूल किताब इत्यादि के संदर्भ बा, दुसरहा स्रोत के संदर्भ चाहऽता',
	'Prose': '{{गद्य}}: लेख में लिस्ट नियर जानकारी बा जेकरा के गद्य में लिखल बेहतर रही',
	'Recentism': '{{हाल के झुकाव}}: लेख हाल के घटना, जानकारी के ओर बेसी झुकाव वाला भ गइल बा',
	'Rough translation': '{{खराब अनुबाद}}: कौनों दुसरे भाषा से घटिया अनुबाद कइल गइल बा',
	'Sections': '{{खंड जरूरी}}: लेख के खंड में बाँट के लिखल बेहतर रही',
	'Self-published': '{{खुद-प्रकाशित}}: बेमतलब आ अनुचित रूप से अपने खुद के प्रकाशित स्रोत के संदर्भ जोड़ल गइल बा',
	'Sources exist': '{{स्रोत मौजूद}}: उल्लेख लायक बिसय जेह पर स्रोत मौजूद हो सके लें बाकी लेख में उनहन के संदर्भ ना बा',
	'Technical': '{{टेक्नीकल}}: आम पढ़वइया खातिर लेख के जानकारी बहुत टेक्नीकल बा',
	'Third-party': '{{तिसरहा-स्रोत}}: लेख में बिसय से नजदीकी से संबंधित चीजन के संदर्भ बा, तिसरा पार्टी के ना',
	'Tone': '{{लहजा}}: लेख के लहजा ज्ञानकोश वाला नइखे जइसन कि विकिपीडिया पर होखे के चाहीं',
	'Too few opinions': '{{कम राय}}: सगरी महत्व के राय भा व्यू नइखे लिखल गइल',
	'Uncategorized': '{{श्रेणी नइखे}}: लेख कौनों श्रेणी में ना जुड़ल बा',
	'Under construction': '{{निर्माणाधीन}}: नाया लेख में अभिन बिस्तार हो रहल बा, या दोबारा लिखल जा रहल बा',
	'Underlinked': '{{कड़ी कम}}: दुसरे लेखन के अउरी विकिकड़ी लेख में जोड़े के जरूरत बा',
	'Undue weight': '{{अनुचित वजन}}: कौनों बिचार, घटना भा बिबाद परजरूरत से बेसी वजन दे के लिखल बा',
	'Unfocused': '{{बिना फोकस}}: लेख के मूल फोकस बिसय से हट के दुसरी बात पर बाटे',
	'Unreferenced': '{{बिना स्रोत}}: लेख में कौनों स्रोत से संदर्भ नइखे दिहल गइल',
	'Unreliable sources': '{{अबिस्वसनीय स्रोत}}: संदर्भ बिस्वास जोग ना हो सके लें',
	'Undisclosed paid': '{{पेमेंट पर बनावल}}: होसके ला लेख कौनों बिना घोषित पेमेंट के बदले लिखल/संपादित कइल होखे',
	'Update': '{{अपडेट}}: अउरी हाल के जानकारी जोड़ के लेख के अपडेट करे के जरूरत बा',
	'Very long': '{{बहुत लंबा}}: लेख बेमतलब बहुत लंबा बा आ पढ़े में दिक्कत पैदा करत हो सके ला',
	'Weasel': '{{लफ्फाजी}}: लेख के तटस्थता आ सत्यापन जोग होखल लफ्फाजी वाला शब्द के इस्तेमाल के कारन घट गइल बा'
};

// A list of tags in order of category
// Tags should be in alphabetical order within the categories
// Add new categories with discretion - the list is long enough as is!

Twinkle.tag.article.tagCategories = {
	'सफाई आ रखरखाव टैग': {
		'आम सफाई के कारन': [
			'Cleanup',  // has a subgroup with text input
			'Cleanup rewrite',
			'Copy edit'  // has a subgroup with text input
		],
		'अनुचित सामग्री': [
			'Close paraphrasing',
			'Copypaste',  // has a subgroup with text input
			'External links',
			'Non-free'
		],
		'संरचना, फारमेटिंग आ भूमिका': [
			'Cleanup reorganize',
			'Condense',
			'Lead missing',
			'Lead rewrite',
			'Lead too long',
			'Lead too short',
			'Sections',
			'Very long'
		],
		'कथा-कहानी, फिक्शन संबंधी सफाई': [
			'All plot',
			'Fiction',
			'In-universe',
			'Long plot',
			'No plot'
		]
	},
	'सामग्री संबंधी आम समस्या': {
		'महत्व आ ज्ञानकोशलायक': [
			'Notability'  // has a subgroup with subcategories
		],
		'लिखे के इस्टाइल': [
			'Advert',
			'Cleanup tense',
			'Essay-like',
			'Fanpov',
			'Manual',
			'Cleanup-PR',
			'Over-quotation',
			'Prose',
			'Technical',
			'Tone'
		],
		'बुझाए (भा न बुझाए) लायक': [
			'Confusing',
			'Incomprehensible',
			'Unfocused'
		],
		'जानकारी आ बिबरन': [
			'Context',
			'Expert needed',
			'Overly detailed',
			'Undue weight'
		],
		'समय आधारित मुद्दा': [
			'Current',
			'Update'
		],
		'तटस्थ नजरिया, पक्षपात आ फैक्ट के सटीकता': [
			'Autobiography',
			'COI',
			'Disputed',
			'Hoax',
			'Globalize',
			'Peacock',
			'POV',
			'Recentism',
			'Too few opinions',
			'Undisclosed paid',
			'Weasel'
		],
		'सत्यापन आ स्रोत समस्या': [
			'BLP sources',
			'BLP unsourced',
			'More citations needed',
			'One source',
			'Original research',
			'Primary sources',
			'Self-published',
			'Sources exist',
			'Third-party',
			'Unreferenced',
			'Unreliable sources'
		]
	},
	'बिसेस सामग्री समस्या आ मुद्दा': {
		'भाषा': [
			'Not Bhojpuri',  // has a subgroup with several options
			'Rough translation',  // has a subgroup with several options
			'Expand language'
		],
		'कड़ी': [
			'Dead end',
			'Orphan',
			'Overlinked',
			'Underlinked'
		],
		'संदर्भ के टेकनीक': [
			'Citation style',
			'Cleanup bare URLs',
			'More footnotes',
			'No footnotes'
		],
		'श्रेणी संबंधी': [
			'Improve categories',
			'Uncategorized'
		]
	},
	'विलय संबंधी': [
		'History merge',
		'Merge',   // these three have a subgroup with several options
		'Merge from',
		'Merge to'
	],
	'सूचना संबंधी टैग': [
		'In use',
		'Under construction'
	]
};

// A list of tags in order of Bhojpuri aphabets grouped into four categories

Twinkle.tag.article.tagBhojpuri = {
	'अक्सरहा इस्तेमाल होखे वाला': [
		'Cleanup',  // has a subgroup with text input
		'Not Bhojpuri',  // has a subgroup with several options
		'Essay-like',
		'Fiction',
		'Update',
		'External links',
		'Unreferenced'
		],
	'अच्छर क्रम में': [
		'Dead end',
		'More footnotes',
		'Improve categories',
		'More citations needed',
		'Orphan',
		'Undue weight',
		'Update',
		'Unreliable sources',
		'Incomprehensible',
		'Autobiography',
		'History merge',
		'In use',
		'Notability',
		'One source',
		'Condense',
		'Underlinked',
		'Fiction',
		'In-universe',
		'No plot',
		'Long plot',
		'Confusing',
		'Too few opinions',
		'All plot',
		'Copy edit',
		'Copypaste',
		'Sections',
		'Rough translation',
		'Self-published',
		'Prose',
		'Manual',
		'Non-free',
		'BLP unsourced',
		'BLP sources',
		'Technical',
		'Third-party',
		'Hoax',
		'POV',
		'COI',
		'Essay-like',
		'Under construction',
		'Advert',
		'Undisclosed paid',
		'Close paraphrasing',
		'Fanpov',
		'Context',
		'Primary sources',
		'No footnotes',
		'Overlinked',
		'Over-quotation',
		'Overly detailed',
		'Very long',
		'External links',
		'Unfocused',
		'Unreferenced',
		'Disputed',
		'Expert needed',
		'Globalize',
		'Expand language',
		'Lead too short',
		'Lead rewrite',
		'Lead missing',
		'Lead too long',
		'Not Bhojpuri',
		'Original research',
		'Merge to',
		'Weasel',
		'Tone',
		'Merge',
		'Uncategorized',
		'Peacock',
		'Cleanup tense',
		'Cleanup rewrite',
		'Cleanup-PR',
		'Cleanup reorganize',
		'Cleanup bare URLs',
		'Cleanup',
		'Merge from',
		'Sources exist',
		'Citation style',
		'Current',
		'Recentism'
	]
};

// Contains those article tags that *do not* work inside {{multiple issues}}.
Twinkle.tag.multipleIssuesExceptions = [
	'Copypaste',
	'Current', // Works but not intended for use in MI
	'Expand language',
	'History merge',
	'Improve categories',
	'In use',
	'Merge',
	'Merge from',
	'Merge to',
	'Not Bhojpuri',
	'Rough translation',
	'Uncategorized',
	'Under construction'
];

// Tags for REDIRECTS start here

Twinkle.tag.spellingList = [
	{
		label: '{{R from acronym}}: शार्टफार्म (एक्रोनिम) से अनुप्रेषण',
		value: 'R from acronym'
	},
	{
		label: '{{R from alternative spelling}}: दुसरे हिज्जे (इस्पेलिंग) से अनुप्रेषण',
		value: 'R from alternative spelling'
	},
	{
		label: '{{R from initialism}}: नाँव के छोट रूप से अनुप्रेषण',
		value: 'R from initialism'
	},
	{
		label: '{{R from ASCII-only}}: बेसिक ASCII में टाइटिल से फार्मल टाइटल पर से अनुप्रेषण',
		value: 'R from ASCII-only'
	},
	{
		label: '{{R from member}}: कौनो ग्रुप से मेंबर के नाँव से ओह ग्रुप, संस्था, टीम पर अनुप्रेषण',
		value: 'R from member'
	},
	{
		label: '{{R from misspelling}}: गलत इस्पेलिंग भा टाइपोग्राफिक गलती से अनुप्रेषण',
		value: 'R from misspelling'
	},
	{
		label: '{{R from modification}}: लेख के नाँव में सुधार/बदलाव से अनुप्रेषण, मने कि उहे शब्द दोबारा एहर ओहर बदल गइल होखें',
		value: 'R from modification'
	},
	{
		label: '{{R from plural}}: बहुवचन से एकवचन पर अनुप्रेषण',
		value: 'R from plural'
	},
	{
		label: '{{R from related word}}: संबंधित शब्द से अनुप्रेषण',
		value: 'R from related word'
	},
	{
		label: '{{R to list entry}}: मामूली उल्लेखनीयता वाला नाँव के लिस्ट से ओही बिसय के लेख पर अनुप्रेषण',
		value: 'R to list entry'
	},
	{
		label: '{{R to section}}: ओइसने जइसे {{R to list entry}}, बाकी जब लिस्ट खंड में बेवस्थित रहे',
		value: 'R to section'
	},
	{
		label: '{{R with possibilities}}: बिसिष्ट टाइटिल से आम टाइटिल पर, जब लेख के ओह नाँव से खोजल जाए के संभावना होखे',
		value: 'R with possibilities'
	}
];

Twinkle.tag.alternativeList = [
	{
		label: '{{R from alternative language}}: दुसरे भाषा के नाँव से अनुप्रेषण',
		value: 'R from alternative language',
		subgroup: [
			{
				name: 'altLangFrom',
				type: 'input',
				label: 'भाषा कोड (जवना भाषा से): ',
				tooltip: 'दू अच्छर के भाषा कोड दिहल जाय; जर्मन खातिर "de" नियर।'
			},
			{
				name: 'altLangTo',
				type: 'input',
				label: 'भाषा कोड (जवना भाषा पर): ',
				tooltip: 'जवना भाषा के नाँव पर अनुप्रेषण बा ओकर दू अच्छर के कोड'
			},
			{
				name: 'altLangInfo',
				type: 'div',
				label: $.parseHTML('<p>भाषा सभ के कोड के लिस्ट खातिर देखीं<a href="/wiki/Wp:Template_messages/Redirect_language_codes">Wikipedia:Template messages/Redirect language codes</a></p>')
			}
		]
	},
	{
		label: '{{R from alternative name}}: दूसर नाँव, कलम नाँव, पुकार नाँव, पर्यायवाची इत्यादि पर अनुप्रेषण',
		value: 'R from alternative name'
	},
	{
		label: '{{R from former name}}: पुराना नाँव से अनुप्रेषण',
		value: 'R from former name'
	},
	{
		label: '{{R from historic name}}: देस, राज्य, शहर इत्यादि के इतिहासी नाँव से अनुप्रेषण',
		value: 'R from historic name'
	},
	{
		label: '{{R from incorrect name}}: ऊटपटांग नाँव जे टाइटिल लायक न होखे, से अनुप्रेषण',
		value: 'R from incorrect name'
	},
	{
		label: '{{R from long name}}: पूरा भा बेसी लमहर नाँव से अनुप्रेषण',
		value: 'R from long name'
	},
	{
		label: '{{R from molecular formula}}: केमिकल फार्मूला से अनुप्रेषण',
		value: 'R from molecular formula'
	},
	{
		label: '{{R from name and country}}: देश के बिसिष्ट नाँव से चलनसार छोट नाँव पर अनुप्रेषण',
		value: 'R from name and country'
	},
	{
		label: '{{R from phrase}}: वाक्य के टुकड़ा से संबंधित बिसय पर अनुप्रेषण',
		value: 'R from phrase'
	},
	{
		label: '{{R from scientific name}}: बैज्ञानिक नाँव से अनुप्रेषण',
		value: 'R from scientific name'
	},
	{
		label: '{{R from short name}}: ब्यक्ति, किताब फिलिम इत्यादि के शार्ट फार्म नाँव से अनुप्रेषण',
		value: 'R from short name'
	},
	{
		label: '{{R from subtopic}}: उपबिसय से बड़ बिसय वाला लेख पर अनुप्रेषण',
		value: 'R from subtopic'
	},
	{
		label: '{{R from surname}}: उपनाम से अनुप्रेषण',
		value: 'R from surname'
	},
	{
		label: '{{R to diacritic}}: डायाक्रिटिक चीन्हा सभ वाला टाइटिल से अनुप्रेषण',
		value: 'R to diacritic'
	},
	{
		label: '{{R to related topic}}: संबंधित भा मिलत-जुलत बिसय से अनुप्रेषण',
		value: 'R to related topic'
	},
	{
		label: '{{R to scientific name}}: आम नाँव से बैज्ञानिक नाँव पर अनुप्रेषण',
		value: 'R to scientific name'
	}
];

Twinkle.tag.administrativeList = [
	{
		label: '{{R from ambiguous term}}: भरमाव वाला शब्द से ओह पन्ना पर जहाँ बहुअर्थी लिस्ट बा (जब ओह में "बहुअर्थी" शब्द के इस्तेमाल न होखे)',
		value: 'R from ambiguous term'
	},
	{
		label: '{{R to decade}}: साल से दशक पर अनुप्रेषण',
		value: 'R to decade'
	},
	{
		label: '{{R to disambiguation page}}: बहुअर्थी पन्ना पर',
		value: 'R to disambiguation page'
	},
	{
		label: '{{R from duplicated article}}: डुप्लीकेट लेख से, जब इतिहास सहेज के रखे के होखे',
		value: 'R from duplicated article'
	},
	{
		label: '{{R from file metadata link}}: EXIF, XMP नियर चीज से बने वाली विकिकड़ी से अनुप्रेषण',
		value: 'R from file metadata link'
	},
	{
		label: '{{R with history}}: जब इतिहास सहेजे के मूल पन्ना पर रखे के होखे',
		value: 'R with history'
	},
	{
		label: '{{R from incomplete disambiguation}}: जब नाँव एतना भरमाव वाला होखे कि कौनों लेख पर ना बलुक सबसे उचित बहुअर्थी पन्ना पर अनुप्रेषण बनावे के पड़े',
		value: 'R from incomplete disambiguation'
	},
	{
		label: '{{R from merge}}: विलय से बनल अनुप्रेषण, जब इतिहास सुरक्षित राखे के होखे',
		value: 'R from merge'
	},
	{
		label: '{{R from other disambiguation}}: जब बहुअर्थी के निशानदेही वाला शब्द एगो अउरी दूसर होखे',
		value: 'R from other disambiguation'
	},
	{
		label: '{{R printworthy}}: अइसन टाइटिल जे प्रिंट में, सीडी/डीवीडी में उचित रही बाकी विकिपीडिया पर ना',
		value: 'R printworthy'
	},
	{
		label: '{{R from school}}: बहुत कम जानकारी वाला इस्कूल के लेख से जगह के लेख पर',
		value: 'R from school'
	},
	{
		label: '{{R from shortcut}}: विकिपीडिया शार्टकट से अनुप्रेषण',
		value: 'R from shortcut'
	},
	{
		label: '{{R from sort name}}: छोट नाँव से अनुप्रेषण, या अइसन जेह में उपनाँव पहिले रख के बनावल गइल होखे',
		value: 'R from sort name'
	},
	{
		label: '{{R unprintworthy}}: जवन प्रिंट भा सीडी/डीवीडी के लायक ना होखे',
		value: 'R unprintworthy'
	}
];

// maintenance tags for FILES start here

Twinkle.tag.file = {};

Twinkle.tag.file.licenseList = [
	{ label: '{{Bsr}}: source info consists of bare image URL/generic base URL only', value: 'Bsr' },
	{ label: '{{Non-free reduce}}: non-low-resolution fair use image (or too-long audio clip, etc)', value: 'Non-free reduce' },
	{ label: '{{Orphaned non-free revisions}}: fair use media with old revisions that need to be deleted', value: 'subst:orfurrev' }
];

Twinkle.tag.file.commonsList = [
	{ label: '{{Copy to Commons}}: free media that should be copied to Commons', value: 'Copy to Commons' },
	{ label: '{{Do not move to Commons}} (PD issue): file is PD in the US but not in country of origin', value: 'Do not move to Commons' },
	{
		label: '{{Do not move to Commons}} (other reason)',
		value: 'Do not move to Commons_reason',
		subgroup: {
			type: 'input',
			name: 'DoNotMoveToCommons',
			label: 'Reason: ',
			tooltip: 'Enter the reason why this image should not be moved to Commons (required)'
		}
	},
	{
		label: '{{Keep local}}: request to keep local copy of a Commons file',
		value: 'Keep local',
		subgroup: {
			type: 'input',
			name: 'keeplocalName',
			label: 'Commons image name if different: ',
			tooltip: 'Name of the image on Commons (if different from local name), excluding the File: prefix:'
		}
	},
	{
		label: '{{Now Commons}}: file has been copied to Commons',
		value: 'subst:ncd',
		subgroup: {
			type: 'input',
			name: 'ncdName',
			label: 'Commons image name if different: ',
			tooltip: 'Name of the image on Commons (if different from local name), excluding the File: prefix:'
		}
	}
];

Twinkle.tag.file.cleanupList = [
	{ label: '{{Artifacts}}: PNG contains residual compression artifacts', value: 'Artifacts' },
	{ label: '{{Bad font}}: SVG uses fonts not available on the thumbnail server', value: 'Bad font' },
	{ label: '{{Bad format}}: PDF/DOC/... file should be converted to a more useful format', value: 'Bad format' },
	{ label: '{{Bad GIF}}: GIF that should be PNG, JPEG, or SVG', value: 'Bad GIF' },
	{ label: '{{Bad JPEG}}: JPEG that should be PNG or SVG', value: 'Bad JPEG' },
	{ label: '{{Bad trace}}: auto-traced SVG requiring cleanup', value: 'Bad trace' },
	{
		label: '{{Cleanup image}}: general cleanup', value: 'Cleanup image',
		subgroup: {
			type: 'input',
			name: 'cleanupimageReason',
			label: 'Reason: ',
			tooltip: 'Enter the reason for cleanup (required)'
		}
	},
	{ label: '{{ClearType}}: image (not screenshot) with ClearType anti-aliasing', value: 'ClearType' },
	{ label: '{{Imagewatermark}}: image contains visible or invisible watermarking', value: 'Imagewatermark' },
	{ label: '{{NoCoins}}: image using coins to indicate scale', value: 'NoCoins' },
	{ label: '{{Overcompressed JPEG}}: JPEG with high levels of artifacts', value: 'Overcompressed JPEG' },
	{ label: '{{Opaque}}: opaque background should be transparent', value: 'Opaque' },
	{ label: '{{Remove border}}: unneeded border, white space, etc.', value: 'Remove border' },
	{
		label: '{{Rename media}}: file should be renamed according to the criteria at [[WP:FMV]]',
		value: 'Rename media',
		subgroup: [
			{
				type: 'input',
				name: 'renamemediaNewname',
				label: 'New name: ',
				tooltip: 'Enter the new name for the image (optional)'
			},
			{
				type: 'input',
				name: 'renamemediaReason',
				label: 'Reason: ',
				tooltip: 'Enter the reason for the rename (optional)'
			}
		]
	},
	{ label: '{{Should be PNG}}: GIF or JPEG should be lossless', value: 'Should be PNG' },
	{
		label: '{{Should be SVG}}: PNG, GIF चाहे JPEG जे वेक्टर ग्राफिक्स में होखे के चाहीं', value: 'Should be SVG',
		subgroup: {
			name: 'svgCategory',
			type: 'select',
			list: [
				{ label: '{{Should be SVG|other}}', value: 'other' },
				{ label: '{{Should be SVG|alphabet}}: character images, font examples, etc.', value: 'alphabet' },
				{ label: '{{Should be SVG|chemical}}: chemical diagrams, etc.', value: 'chemical' },
				{ label: '{{Should be SVG|circuit}}: electronic circuit diagrams, etc.', value: 'circuit' },
				{ label: '{{Should be SVG|coat of arms}}: coats of arms', value: 'coat of arms' },
				{ label: '{{Should be SVG|diagram}}: diagrams that do not fit any other subcategory', value: 'diagram' },
				{ label: '{{Should be SVG|emblem}}: emblems, free/libre logos, insignias, etc.', value: 'emblem' },
				{ label: '{{Should be SVG|fair use}}: fair-use images, fair-use logos', value: 'fair use' },
				{ label: '{{Should be SVG|flag}}: flags', value: 'flag' },
				{ label: '{{Should be SVG|graph}}: visual plots of data', value: 'graph' },
				{ label: '{{Should be SVG|logo}}: logos', value: 'logo' },
				{ label: '{{Should be SVG|map}}: maps', value: 'map' },
				{ label: '{{Should be SVG|music}}: musical scales, notes, etc.', value: 'music' },
				{ label: '{{Should be SVG|physical}}: "realistic" images of physical objects, people, etc.', value: 'physical' },
				{ label: '{{Should be SVG|symbol}}: miscellaneous symbols, icons, etc.', value: 'symbol' }
			]
		}
	},
	{ label: '{{Should be text}}: image should be represented as text, tables, or math markup', value: 'Should be text' }
];

Twinkle.tag.file.qualityList = [
	{ label: '{{Image-blownout}}', value: 'Image-blownout' },
	{ label: '{{Image-out-of-focus}}', value: 'Image-out-of-focus' },
	{
		label: '{{Image-Poor-Quality}}', value: 'Image-Poor-Quality',
		subgroup: {
			type: 'input',
			name: 'ImagePoorQualityReason',
			label: 'Reason: ',
			tooltip: 'Enter the reason why this image is so bad (required)'
		}
	},
	{ label: '{{Image-underexposure}}', value: 'Image-underexposure' },
	{
		label: '{{Low quality chem}}: disputed chemical structures', value: 'Low quality chem',
		subgroup: {
			type: 'input',
			name: 'lowQualityChemReason',
			label: 'Reason: ',
			tooltip: 'Enter the reason why the diagram is disputed (required)'
		}
	}
];

Twinkle.tag.file.replacementList = [
	{ label: '{{Duplicate}}: exact duplicate of another file, but not yet orphaned', value: 'Duplicate' },
	{ label: '{{Obsolete}}: improved version available', value: 'Obsolete' },
	{ label: '{{PNG version available}}', value: 'PNG version available' },
	{ label: '{{Vector version available}}', value: 'Vector version available' }
];
Twinkle.tag.file.replacementList.forEach(function(el) {
	el.subgroup = {
		type: 'input',
		label: 'Replacement file: ',
		tooltip: 'Enter the name of the file which replaces this one (required)',
		name: el.value.replace(/ /g, '_') + 'File'
	};
});


Twinkle.tag.callbacks = {
	article: function articleCallback(pageobj) {

		// Remove tags that become superfluous with this action
		var pageText = pageobj.getPageText().replace(/\{\{\s*([Uu]serspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/g, '');
		var summaryText;
		var params = pageobj.getCallbackParameters();

		/**
		 * Saves the page following the removal of tags if any. The last step.
		 * Called from removeTags()
		 */
		var postRemoval = function() {

			if (params.tagsToRemove.length) {
				// Finish summary text
				summaryText += (params.tagsToRemove.length > 1 ? ' टैग हटावल जात बाड़ें' : ' टैग हटावल जात बा');

				// Remove empty {{multiple issues}} if found
				pageText = pageText.replace(/\{\{(multiple ?issues|article ?issues|mi)\s*\|\s*\}\}\n?/im, '');
				// Remove single-element {{multiple issues}} if found
				pageText = pageText.replace(/\{\{(?:multiple ?issues|article ?issues|mi)\s*\|\s*(\{\{[^}]+\}\})\s*\}\}/im, '$1');
			}

			// avoid truncated summaries
			if (summaryText.length > (254 - Twinkle.getPref('summaryAd').length)) {
				summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
			}

			pageobj.setPageText(pageText);
			pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
			pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
			pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
			pageobj.setCreateOption('nocreate');
			pageobj.save(function() {
				// special functions for merge tags
				if (params.mergeReason) {
					// post the rationale on the talk page (only operates in main namespace)
					var talkpageText = '\n\n== ' + params.talkDiscussionTitle + ' ==\n\n';
					talkpageText += params.mergeReason.trim() + ' ~~~~';
					var talkpage = new Morebits.wiki.page('Talk:' + params.discussArticle, 'बातचीत पन्ना पर कारन पोस्ट कइल जात बा');
					talkpage.setAppendText(talkpageText);
					talkpage.setEditSummary('/* ' + params.talkDiscussionTitle + ' */ new section' + Twinkle.getPref('summaryAd'));
					talkpage.setWatchlist(Twinkle.getPref('watchMergeDiscussions'));
					talkpage.setCreateOption('recreate');
					talkpage.append();
				}
				if (params.mergeTagOther) {
					// tag the target page if requested
					var otherTagName = 'Merge';
					if (params.mergeTag === 'Merge from') {
						otherTagName = 'Merge to';
					} else if (params.mergeTag === 'Merge to') {
						otherTagName = 'Merge from';
					}
					var newParams = {
						tags: [otherTagName],
						tagsToRemove: [],
						tagsToRemain: [],
						mergeTarget: Morebits.pageNameNorm,
						discussArticle: params.discussArticle,
						talkDiscussionTitle: params.talkDiscussionTitle
					};
					var otherpage = new Morebits.wiki.page(params.mergeTarget, 'दुसरका पन्ना (' +
						params.mergeTarget + ') पर टैग जोड़ल जात बा');
					otherpage.setCallbackParameters(newParams);
					otherpage.load(Twinkle.tag.callbacks.article);
				}

				// post at WP:PNT for {{Not Bhojpuri}} and {{rough translation}} tag
				if (params.translationPostAtPNT) {
					var pntPage = new Morebits.wiki.page('विकिपीडिया:अनुबाद अनुरोध',
						'लेख के अनुबाद अनुरोध पन्ना पर भोजपुरी अनुबाद खाती लिस्ट में जोड़ल जात बा');
					pntPage.setFollowRedirect(true);
					pntPage.setCallbackParameters({
						template: params.tags.indexOf('Rough translation') !== -1 ? 'duflu' : 'needtrans',
						lang: params.translationLanguage,
						reason: params.translationComments
					});
					pntPage.load(function friendlytagCallbacksTranslationListPage(pageobj) {
						var old_text = pageobj.getPageText();
						var params = pageobj.getCallbackParameters();
						var statelem = pageobj.getStatusElement();

						var templateText = '{{subst:' + params.template + '|pg=' + Morebits.pageNameNorm + '|Language=' +
							(params.lang || 'uncertain') + '|Comments=' + params.reason.trim() + '}} ~~~~';

						var text, summary;
						if (params.template === 'duflu') {
							text = old_text + '\n\n' + templateText;
							summary = 'अनुबाद सफाई के अनुरोध ';
						} else {
							text = old_text.replace(/\n+(==\s?Translated pages that could still use some cleanup\s?==)/,
								'\n\n' + templateText + '\n\n$1');
							summary = (params.lang ? ' से ' + params.lang : '') + ' में अनुबाद अनुरोध ';
						}

						if (text === old_text) {
							statelem.error('चर्चा के जगह पावे में बिफल रहल');
							return;
						}
						pageobj.setPageText(text);
						pageobj.setEditSummary(summary + ' [[:' + Morebits.pageNameNorm + ']]' + Twinkle.getPref('summaryAd'));
						pageobj.setCreateOption('recreate');
						pageobj.save();
					});
				}
				if (params.translationNotify) {
					pageobj.lookupCreation(function(innerPageobj) {
						var initialContrib = innerPageobj.getCreator();

						// Disallow warning yourself
						if (initialContrib === mw.config.get('wgUserName')) {
							innerPageobj.getStatusElement().warn('(' + initialContrib + ') आप खुदे एह पन्ना के बनावे वाला बाड़ीं, नोटिस छोड़ल जात बा');
							return;
						}

						var userTalkPage = new Morebits.wiki.page('प्रयोगकर्ता वार्ता:' + initialContrib,
							'शुरुआती योगदानकर्ता (' + initialContrib + ') के नोटिस भेजल जात बा ');
						var notifytext = '\n\n== राउर लेख [[' + Morebits.pageNameNorm + ']]==\n' +
							'{{subst:uw-notenglish|1=' + Morebits.pageNameNorm +
							(params.translationPostAtPNT ? '' : '|nopnt=yes') + '}} ~~~~';
						userTalkPage.setAppendText(notifytext);
						userTalkPage.setEditSummary('नोटिस: भोजपुरी विकिपीडिया पर लिखत घरी भोजपुरी के इस्तमाल करीं' +
							Twinkle.getPref('summaryAd'));
						userTalkPage.setCreateOption('recreate');
						userTalkPage.setFollowRedirect(true);
						userTalkPage.append();
					});
				}
			});

			if (params.patrol) {
				pageobj.patrol();
			}
		};

		/**
		 * Removes the existing tags that were deselected (if any)
		 * Calls postRemoval() when done
		 */
		var removeTags = function removeTags() {

			if (params.tagsToRemove.length === 0) {
				// finish summary text from adding of tags, in this case where there are
				// no tags to be removed
				summaryText += (tags.length > 1 ? ' टैग जोड़ल गइलें' : ' टैग जोड़ल गइल');

				postRemoval();
				return;
			}

			Morebits.status.info('सूचना', 'पहिले से मौजूद टैग सभ में से डीसेलेक्ट कइल सभ के हटावल जात बा');

			if (params.tags.length > 0) {
				summaryText += (tags.length ? '' + (tags.length > 1 ? ' टैग हटावल गइलें' : ' टैग हटावल गइल') : '');
			} else {
				summaryText = '';
			}

			var getRedirectsFor = [];

			// Remove the tags from the page text, if found in its proper name,
			// otherwise moves it to `getRedirectsFor` array earmarking it for
			// later removal
			params.tagsToRemove.forEach(function removeTag(tag, tagIndex) {
				var tag_re = new RegExp('\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]+)?\\}\\}\\n?');

				if (tag_re.test(pageText)) {
					pageText = pageText.replace(tag_re, '');
				} else {
					getRedirectsFor.push('Template:' + tag);
				}

				// Producing summary text for current tag removal
				if (tagIndex > 0) {
					if (tagIndex === (params.tagsToRemove.length - 1)) {
						summaryText += ' and';
					} else if (tagIndex < (params.tagsToRemove.length - 1)) {
						summaryText += ',';
					}
				}
				summaryText += ' {{[[टेम्पलेट:' + tag + '|' + tag + ']]}}';
			});

			if (!getRedirectsFor.length) {
				postRemoval();
				return;
			}

			// Remove tags which appear in page text as redirects
			var api = new Morebits.wiki.api('Getting template redirects', {
				'action': 'query',
				'prop': 'linkshere',
				'titles': getRedirectsFor.join('|'),
				'redirects': 1,  // follow redirect if the class name turns out to be a redirect page
				'lhnamespace': '10',  // template namespace only
				'lhshow': 'redirect',
				'lhlimit': 'max' // 500 is max for normal users, 5000 for bots and sysops
			}, function removeRedirectTag(apiobj) {

				$(apiobj.responseXML).find('page').each(function(idx, page) {
					var removed = false;
					$(page).find('lh').each(function(idx, el) {
						var tag = $(el).attr('title').slice(9);
						var tag_re = new RegExp('\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]*)?\\}\\}\\n?');
						if (tag_re.test(pageText)) {
							pageText = pageText.replace(tag_re, '');
							removed = true;
							return false;   // break out of $.each
						}
					});
					if (!removed) {
						Morebits.status.warn('सूचना', 'पन्ना पर {{' +
						$(page).attr('title').slice(9) + '}} पावे में बिफल रहल... छोड़ल जात बा');
					}

				});

				postRemoval();

			});
			api.post();

		};

		if (!params.tags.length) {
			removeTags();
			return;
		}

		// Executes first: addition of selected tags
		summaryText = '';
		var tagRe, tagText = '', tags = [], groupableTags = [], groupableExistingTags = [], totalTags;

		/**
		 * Updates `tagText` with the syntax of `tagName` template with its parameters
		 * @param {number} tagIndex
		 * @param {string} tagName
		 */
		var addTag = function articleAddTag(tagIndex, tagName) {
			var currentTag = '';
			if (tagName === 'Uncategorized' || tagName === 'Improve categories') {
				pageText += '\n\n{{' + tagName + '|date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}';
			} else {
				currentTag += '{{' + tagName;
				// fill in other parameters, based on the tag
				switch (tagName) {
					case 'Cleanup':
						currentTag += '|reason=' + params.cleanup;
						break;
					case 'Close paraphrasing':
						currentTag += '|source=' + params.closeParaphrasing;
						break;
					case 'Copy edit':
						if (params.copyEdit) {
							currentTag += '|for=' + params.copyEdit;
						}
						break;
					case 'Copypaste':
						if (params.copypaste) {
							currentTag += '|url=' + params.copypaste;
						}
						break;
					case 'Expand language':
						currentTag += '|topic=';
						currentTag += '|langcode=' + params.expandLanguageLangCode;
						if (params.expandLanguageArticle !== null) {
							currentTag += '|otherarticle=' + params.expandLanguageArticle;
						}
						break;
					case 'Expert needed':
						if (params.expertNeeded) {
							currentTag += '|1=' + params.expertNeeded;
						}
						if (params.expertNeededTalk) {
							currentTag += '|talk=' + params.expertNeededTalk;
						}
						if (params.expertNeededReason) {
							currentTag += '|reason=' + params.expertNeededReason;
						}
						break;
					case 'Globalize':
						currentTag += '|1=article';
						if (params.globalizeRegion) {
							currentTag += '|2=' + params.globalizeRegion;
						}
						break;
					case 'News release':
						currentTag += '|1=article';
						break;
					case 'Notability':
						if (params.notability !== 'none') {
							currentTag += '|' + params.notability;
						}
						break;
					case 'Not Bhojpuri':
					case 'Rough translation':
						if (params.translationLanguage) {
							currentTag += '|1=' + params.translationLanguage;
						}
						if (params.translationPostAtPNT) {
							currentTag += '|listed=yes';
						}
						break;
					case 'History merge':
						currentTag += '|originalpage=' + params.histmergeOriginalPage;
						if (params.histmergeReason) {
							currentTag += '|reason=' + params.histmergeReason;
						}
						if (params.histmergeSysopDetails) {
							currentTag += '|details=' + params.histmergeSysopDetails;
						}
						break;
					case 'Merge':
					case 'Merge to':
					case 'Merge from':
						params.mergeTag = tagName;
						// normalize the merge target for now and later
						params.mergeTarget = Morebits.string.toUpperCaseFirstChar(params.mergeTarget.replace(/_/g, ' '));

						currentTag += '|' + params.mergeTarget;

						// link to the correct section on the talk page, for article space only
						if (mw.config.get('wgNamespaceNumber') === 0 && (params.mergeReason || params.discussArticle)) {
							if (!params.discussArticle) {
								// discussArticle is the article whose talk page will contain the discussion
								params.discussArticle = tagName === 'Merge to' ? params.mergeTarget : mw.config.get('wgTitle');
								// nonDiscussArticle is the article which won't have the discussion
								params.nonDiscussArticle = tagName === 'Merge to' ? mw.config.get('wgTitle') : params.mergeTarget;
								var direction = params.nonDiscussArticle + (params.mergeTag === 'Merge' ? ' के साथे ' : ' में ') + params.discussArticle;
								params.talkDiscussionTitle = 'प्रस्तावित विलय ' + direction;
							}
							currentTag += '|discuss=वार्तालाप:' + params.discussArticle + '#' + params.talkDiscussionTitle;
						}
						break;
					default:
						break;
				}

				currentTag += '|date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}\n';
				tagText += currentTag;
			}

			if (tagIndex > 0) {
				if (tagIndex === (totalTags - 1)) {
					summaryText += ' and';
				} else if (tagIndex < (totalTags - 1)) {
					summaryText += ',';
				}
			}

			summaryText += ' {{[[';
			// if it is a custom tag with a parameter
			if (tagName.indexOf('|') !== -1) {
				tagName = tagName.slice(0, tagName.indexOf('|'));
			}
			summaryText += tagName.indexOf(':') !== -1 ? tagName : 'टेम्पलेट:' + tagName + '|' + tagName;
			summaryText += ']]}}';

		};

		/**
		 * Adds the tags which go outside {{multiple issues}}, either because
		 * these tags aren't supported in {{multiple issues}} or because
		 * {{multiple issues}} is not being added to the page at all
		 */
		var addUngroupedTags = function() {
			totalTags = tags.length;
			$.each(tags, addTag);

			// Smartly insert the new tags after any hatnotes or
			// afd, csd, or prod templates or hatnotes. Regex is
			// extra complicated to allow for templates with
			// parameters and to handle whitespace properly.
			pageText = pageText.replace(
				new RegExp(
					// leading whitespace
					'^\\s*' +
					// capture template(s)
					'(?:((?:\\s*' +
					// AfD is special, as the tag includes html comments before and after the actual template
					'(?:<!--.*AfD.*\\n\\{\\{(?:Article for deletion\\/dated|AfDM).*\\}\\}\\n<!--.*(?:\\n<!--.*)?AfD.*(?:\\s*\\n))?|' + // trailing whitespace/newline needed since this subst's a newline
					// begin template format
					'\\{\\{\\s*(?:' +
					// CSD
					'db|delete|db-.*?|speedy deletion-.*?|' +
					// PROD
					'(?:proposed deletion|prod blp)\\/dated(?:\\s*\\|(?:concern|user|timestamp|help).*)+|' +
					// various hatnote templates
					'about|correct title|dablink|distinguish|for|other\\s?(?:hurricaneuses|people|persons|places|uses(?:of)?)|redirect(?:-acronym)?|see\\s?(?:also|wiktionary)|selfref|short description|the' +
					// not a hatnote, but sometimes under a CSD or AfD
					'|salt|proposed deletion endorsed' +
					// end main template name, optionally with a number (such as redirect2)
					')\\d*\\s*' +
					// template parameters
					'(\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?' +
					// end template format
					'\\}\\})+' +
					// end capture
					'(?:\\s*\\n)?)' +
					// trailing whitespace
					'\\s*)?',
					'i'), '$1' + tagText
			);

			removeTags();
		};

		// Separate tags into groupable ones (`groupableTags`) and non-groupable ones (`tags`)
		params.tags.forEach(function(tag) {
			tagRe = new RegExp('\\{\\{' + tag + '(\\||\\}\\})', 'im');
			// regex check for preexistence of tag can be skipped if in canRemove mode
			if (Twinkle.tag.canRemove || !tagRe.exec(pageText)) {
				// condition Twinkle.tag.article.tags[tag] to ensure that its not a custom tag
				// Custom tags are assumed non-groupable, since we don't know whether MI template supports them
				if (Twinkle.tag.article.tags[tag] && Twinkle.tag.multipleIssuesExceptions.indexOf(tag) === -1) {
					groupableTags.push(tag);
				} else {
					tags.push(tag);
				}
			} else {
				if (tag === 'Merge from' || tag === 'History merge') {
					tags.push(tag);
				} else {
					Morebits.status.warn('सूचना', '{{' + tag +
						'}} टैग पहिलहीं से मौजूद बा...छोड़ल जात बा');
					// don't do anything else with merge tags
					if (['Merge', 'Merge to'].indexOf(tag) !== -1) {
						params.mergeTarget = params.mergeReason = params.mergeTagOther = null;
					}
				}
			}
		});

		// To-be-retained existing tags that are groupable
		params.tagsToRemain.forEach(function(tag) {
			if (Twinkle.tag.multipleIssuesExceptions.indexOf(tag) === -1) {
				groupableExistingTags.push(tag);
			}
		});

		var miTest = /\{\{(multiple ?issues|article ?issues|mi)(?!\s*\|\s*section\s*=)[^}]+\{/im.exec(pageText);

		if (miTest && groupableTags.length > 0) {
			Morebits.status.info('सूचना', 'संभव टैग सभ के {{multiple issues}} टैग में लपेट के लगावल जात बा');

			tagText = '';

			totalTags = groupableTags.length;
			$.each(groupableTags, addTag);

			summaryText += (groupableTags.length > 1 ? ' जोड़ल गइलें' : ' जोड़ल गइल') + ' ({{[[टेम्पलेट:multiple issues|multiple issues]]}} में लपेट के)';
			if (tags.length > 0) {
				summaryText += ', आ';
			}

			var miRegex = new RegExp('(\\{\\{\\s*' + miTest[1] + '\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*', 'im');
			pageText = pageText.replace(miRegex, '$1' + tagText + '}}\n');
			tagText = '';

			addUngroupedTags();

		} else if (params.group && !miTest && (groupableExistingTags.length + groupableTags.length) >= 2) {
			Morebits.status.info('सूचना', 'संभव टैग सभ के {{multiple issues}} में लपेटल जात बा');

			tagText += '{{Multiple issues|\n';

			/**
			 * Adds newly added tags to MI
			 */
			var addNewTagsToMI = function() {
				totalTags = groupableTags.length;
				$.each(groupableTags, addTag);
				if (groupableTags.length) {
					summaryText += ' टैग ({{[[टेम्पलेट:multiple issues|multiple issues]]}} में लपेट के)';
				} else {
					summaryText += ' {{[[टेम्पलेट:multiple issues|multiple issues]]}}';
				}
				if (tags.length > 0) {
					summaryText += ', आ';
				}
				tagText += '}}\n';

				addUngroupedTags();
			};


			var getRedirectsFor = [];

			// Reposition the tags on the page into {{multiple issues}}, if found with its
			// proper name, else moves it to `getRedirectsFor` array to be handled later
			groupableExistingTags.forEach(function repositionTagIntoMI(tag) {
				var tag_re = new RegExp('(\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]+)?\\}\\}\\n?)');
				if (tag_re.test(pageText)) {
					tagText += tag_re.exec(pageText)[1];
					pageText = pageText.replace(tag_re, '');
				} else {
					getRedirectsFor.push('टेम्पलेट:' + tag);
				}
			});

			if (!getRedirectsFor.length) {
				addNewTagsToMI();
				return;
			}

			var api = new Morebits.wiki.api('टेम्पलेट अनुप्रेषण हासिल कइल जात बा', {
				'action': 'query',
				'prop': 'linkshere',
				'titles': getRedirectsFor.join('|'),
				'redirects': 1,
				'lhnamespace': '10', // template namespace only
				'lhshow': 'redirect',
				'lhlimit': 'max' // 500 is max for normal users, 5000 for bots and sysops
			}, function replaceRedirectTag(apiobj) {
				$(apiobj.responseXML).find('page').each(function(idx, page) {
					var found = false;
					$(page).find('lh').each(function(idx, el) {
						var tag = $(el).attr('title').slice(9);
						var tag_re = new RegExp('(\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]*)?\\}\\}\\n?)');
						if (tag_re.test(pageText)) {
							tagText += tag_re.exec(pageText)[1];
							pageText = pageText.replace(tag_re, '');
							found = true;
							return false;   // break out of $.each
						}
					});
					if (!found) {
						Morebits.status.warn('सूचना', 'पन्ना परपहिले से मौजूद {{' +
						$(page).attr('title').slice(9) + '}} पावे में बिफल... अस्थान बदलाव छोड़ल जात बा');
					}
				});
				addNewTagsToMI();
			});
			api.post();

		} else {
			tags = tags.concat(groupableTags);
			addUngroupedTags();
		}

	},

	redirect: function redirect(pageobj) {
		var params = pageobj.getCallbackParameters(),
			pageText = pageobj.getPageText(),
			tagRe, tagText = '', summaryText = '',
			tags = [], i;

		for (i = 0; i < params.tags.length; i++) {
			tagRe = new RegExp('(\\{\\{' + params.tags[i] + '(\\||\\}\\}))', 'im');
			if (!tagRe.exec(pageText)) {
				tags.push(params.tags[i]);
			} else {
				Morebits.status.warn('सूचना', '{{' + params.tags[i] +
					'}} अनुप्रेषण पर पहिलहीं मौजूद बा...छोड़ल जात बा');
			}
		}

		var addTag = function redirectAddTag(tagIndex, tagName) {
			tagText += '\n{{' + tagName;
			if (tagName === 'R from alternative language') {
				if (params.altLangFrom) {
					tagText += '|from=' + params.altLangFrom;
				}
				if (params.altLangTo) {
					tagText += '|to=' + params.altLangTo;
				}
			}
			tagText += '}}';

			if (tagIndex > 0) {
				if (tagIndex === (tags.length - 1)) {
					summaryText += ' and';
				} else if (tagIndex < (tags.length - 1)) {
					summaryText += ',';
				}
			}

			summaryText += ' {{[[:' + (tagName.indexOf(':') !== -1 ? tagName : 'टेम्पलेट:' + tagName + '|' + tagName) + ']]}}';
		};

		tags.sort();
		$.each(tags, addTag);

		// Check for all Rcat shell redirects (from #433)
		if (pageText.match(/{{(?:redr|this is a redirect|r(?:edirect)?(?:.?cat.*)?[ _]?sh)/i)) {
			// Regex inspired by [[User:Kephir/gadgets/sagittarius.js]] ([[Special:PermaLink/831402893]])
			var oldTags = pageText.match(/(\s*{{[A-Za-z ]+\|)((?:[^|{}]*|{{[^}]*}})+)(}})\s*/i);
			pageText = pageText.replace(oldTags[0], oldTags[1] + tagText + oldTags[2] + oldTags[3]);
		} else {
			// Fold any pre-existing Rcats into taglist and under Rcatshell
			var pageTags = pageText.match(/\n{{R(?:edirect)? .*?}}/img);
			var oldPageTags = '';
			if (pageTags) {
				pageTags.forEach(function(pageTag) {
					var pageRe = new RegExp(pageTag, 'img');
					pageText = pageText.replace(pageRe, '');
					oldPageTags += pageTag;
				});
			}
			pageText += '\n{{Redirect category shell|' + tagText + oldPageTags + '\n}}';
		}

		summaryText += (tags.length > 0 ? '' + (tags.length > 1 ? ' जोड़ल गइलें' : ' जोड़ल गइल') : '');

		// avoid truncated summaries
		if (summaryText.length > (254 - Twinkle.getPref('summaryAd').length)) {
			summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
		}

		pageobj.setPageText(pageText);
		pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
		pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
		pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
		pageobj.setCreateOption('nocreate');
		pageobj.save();

		if (params.patrol) {
			pageobj.patrol();
		}

	},

	file: function friendlytagCallbacksFile(pageobj) {
		var text = pageobj.getPageText();
		var params = pageobj.getCallbackParameters();
		var summary = '';

		// Add maintenance tags
		if (params.tags.length) {

			var tagtext = '', currentTag;
			$.each(params.tags, function(k, tag) {
				// when other commons-related tags are placed, remove "move to Commons" tag
				if (['Keep local', 'subst:ncd', 'Do not move to Commons_reason', 'Do not move to Commons',
					'Now Commons'].indexOf(tag) !== -1) {
					text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, '');
				}

				currentTag = '{{' + (tag === 'Do not move to Commons_reason' ? 'Do not move to Commons' : tag);

				switch (tag) {
					case 'subst:ncd':
						if (params.ncdName !== '') {
							currentTag += '|1=' + params.ncdName;
						}
						break;
					case 'Keep local':
						if (params.keeplocalName !== '') {
							currentTag += '|1=' + params.keeplocalName;
						}
						break;
					case 'Rename media':
						if (params.renamemediaNewname !== '') {
							currentTag += '|1=' + params.renamemediaNewname;
						}
						if (params.renamemediaReason !== '') {
							currentTag += '|2=' + params.renamemediaReason;
						}
						break;
					case 'Cleanup image':
						currentTag += '|1=' + params.cleanupimageReason;
						break;
					case 'Image-Poor-Quality':
						currentTag += '|1=' + params.ImagePoorQualityReason;
						break;
					case 'Low quality chem':
						currentTag += '|1=' + params.lowQualityChemReason;
						break;
					case 'Vector version available':
						text = text.replace(/\{\{((convert to |convertto|should be |shouldbe|to)?svg|badpng|vectorize)[^}]*\}\}/gi, '');
						/* falls through */
					case 'PNG version available':
						/* falls through */
					case 'Obsolete':
						/* falls through */
					case 'Duplicate':
						currentTag += '|1=' + params[tag.replace(/ /g, '_') + 'File'];
						break;
					case 'Do not move to Commons_reason':
						currentTag += '|reason=' + params.DoNotMoveToCommons;
						break;
					case 'subst:orfurrev':
						// remove {{non-free reduce}} and redirects
						text = text.replace(/\{\{\s*(Template\s*:\s*)?(Non-free reduce|FairUseReduce|Fairusereduce|Fair Use Reduce|Fair use reduce|Reduce size|Reduce|Fair-use reduce|Image-toobig|Comic-ovrsize-img|Non-free-reduce|Nfr|Smaller image|Nonfree reduce)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, '');
						currentTag += '|date={{subst:date}}';
						break;
					case 'Copy to Commons':
						currentTag += '|human=' + mw.config.get('wgUserName');
						break;
					case 'Should be SVG':
						currentTag += '|' + params.svgCategory;
						break;
					default:
						break;  // don't care
				}

				currentTag += '}}\n';

				tagtext += currentTag;
				summary += '{{' + tag + '}}, ';
			});

			if (!tagtext) {
				pageobj.getStatusElement().warn('प्रयोगकर्ता द्वारा कैंसिल; कुछ करे के जरूरत ना बा');
				return;
			}

			text = tagtext + text;
		}

		pageobj.setPageText(text);
		pageobj.setEditSummary(summary.substring(0, summary.length - 2) + Twinkle.getPref('summaryAd'));
		pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
		pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
		pageobj.setCreateOption('nocreate');
		pageobj.save();

		if (params.patrol) {
			pageobj.patrol();
		}
	}
};

Twinkle.tag.callback.evaluate = function friendlytagCallbackEvaluate(e) {
	var form = e.target;
	var params = {};
	if (form.patrolPage) {
		params.patrol = form.patrolPage.checked;
	}

	// Don't return null if there aren't any available tags
	params.tags = form.getChecked(Twinkle.tag.mode + 'Tags') || [];

	// Save values of input fields into params object. This works as quickform input
	// fields within subgroups of elements with name 'articleTags' (say) have their
	// name attribute as 'articleTags.' + name of the subgroup element

	var name_prefix = Twinkle.tag.mode + 'Tags.';
	$(form).find("[name^='" + name_prefix + "']:not(div)").each(function(idx, el) {
		// el are the HTMLInputElements, el.name gives the name attribute
		params[el.name.slice(name_prefix.length)] =
			el.type === 'checkbox' ? form[el.name].checked : form[el.name].value;
	});

	switch (Twinkle.tag.mode) {
		case 'article':
			params.tagsToRemove = form.getUnchecked('alreadyPresentArticleTags') || [];
			params.tagsToRemain = form.getChecked('alreadyPresentArticleTags') || [];

			params.group = form.group.checked;

			// Validation
			if ((params.tags.indexOf('Merge') !== -1) || (params.tags.indexOf('Merge from') !== -1) ||
				(params.tags.indexOf('Merge to') !== -1)) {
				if (((params.tags.indexOf('Merge') !== -1) + (params.tags.indexOf('Merge from') !== -1) +
					(params.tags.indexOf('Merge to') !== -1)) > 1) {
					alert('{{merge}}, {{merge from}}, आ {{merge to}} में से कौनों एकही सेलेक्ट करीं। कई विलय चाहत होखे तब {{merge}} सेलेक्ट करीं आ नाँव सभ पाइप से अलगा के लिखीं, हालाँकि ट्विंकल ओह सभ पर टैग ना लगाईं)।');
					return;
				}
				if (!params.mergeTarget) {
					alert('दुसरहा लेख बताईं');
					return;
				}
				if ((params.mergeTagOther || params.mergeReason) && params.mergeTarget.indexOf('|') !== -1) {
					alert('कई लेख के एक साथ टैग कइल अभिन सपोर्ट नइखे कइल गइल। दोबारा कोसिस करीं।');
					return;
				}
			}
			if ((params.tags.indexOf('Not Bhojpuri') !== -1) && (params.tags.indexOf('Rough translation') !== -1)) {
				alert('{{Not Bhojpuri}} आ {{rough translation}} में से कौनों एकही सेलेक्ट करीं');
				return;
			}
			if (params.tags.indexOf('History merge') !== -1 && params.histmergeOriginalPage.trim() === '') {
				alert('{{history merge}} टैग खातिर आपके कौनों पन्ना बतावे के पड़ी');
				return;
			}
			if (params.tags.indexOf('Cleanup') !== -1 && params.cleanup.trim() === '') {
				alert('{{cleanup}} टैग में सफाई के कारन बतावे के पड़ी');
				return;
			}
			if (params.tags.indexOf('Expand language') !== -1 && params.expandLanguageLangCode.trim() === '') {
				alert('{{expand language}} टैग में आपके भाषा कोड बतावे के पड़ी');
				return;
			}
			break;

		case 'file':

			if (params.tags.indexOf('Cleanup image') !== -1 && params.cleanupimageReason === '') {
				alert('You must specify a reason for the cleanup tag.');
				return;
			}
			if (params.tags.indexOf('Image-Poor-Quality') !== -1 && params.ImagePoorQualityReason === '') {
				alert('You must specify a reason for the {{Image-Poor-Quality}} tag');
				return;
			}
			if (params.tags.indexOf('Low Quality Chem') !== -1 && params.lowQualityChemReason === '') {
				alert('You must specify a reason for the {{Low Quality Chem}} tag');
				return;
			}
			if ((params.tags.indexOf('Duplicate') !== -1 && params.DuplicateFile === '') ||
				(params.tags.indexOf('Obsolete') !== -1 && params.ObsoleteFile === '') ||
				(params.tags.indexOf('PNG version available') !== -1 && params.PNG_version_availableFile === '') ||
				(params.tags.indexOf('Vector version available') !== -1 && params.Vector_version_availableFile === '')
			) {
				alert('You must specify the replacement file name for a tag in the Replacement tags list');
				return;
			}
			if (params.tags.indexOf('Do not move to Commons_reason') !== -1 && params.DoNotMoveToCommons === '') {
				alert('You must specify a reason for the {{Do not move to Commons}} tag');
				return;
			}
			break;

		case 'redirect':
			break;

		default:
			alert('Twinkle.tag: unknown mode ' + Twinkle.tag.mode);
			break;
	}

	// File/redirect: return if no tags selected
	// Article: return if no tag is selected and no already present tag is deselected
	if (params.tags.length === 0 && (Twinkle.tag.mode !== 'article' || params.tagsToRemove.length === 0)) {
		alert('आप के कम से कम एक ठो टैग बीछे के पड़ी!');
		return;
	}

	Morebits.simpleWindow.setButtonsEnabled(false);
	Morebits.status.init(form);

	Morebits.wiki.actionCompleted.redirect = Morebits.pageNameNorm;
	Morebits.wiki.actionCompleted.notice = 'टैगिंग पूरा भइल, पन्ना कुछे सेकेंड में दोबारा लोड होखी';
	if (Twinkle.tag.mode === 'redirect') {
		Morebits.wiki.actionCompleted.followRedirect = false;
	}

	var wikipedia_page = new Morebits.wiki.page(Morebits.pageNameNorm, Twinkle.tag.mode + ' टैग कइल जात बा');
	wikipedia_page.setCallbackParameters(params);
	wikipedia_page.load(Twinkle.tag.callbacks[Twinkle.tag.mode]);

};

})(jQuery);
// </nowiki>