مدیاویکی:Gadget-friendlytag.js

نکته: پس از انتشار ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را پاک کنید.

  • فایرفاکس / سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload کلیک کنید، یا کلید‌های Ctrl-F5 یا Ctrl-R را با هم فشار دهید (در رایانه‌های اپل مکینتاش کلید‌های ⌘-R)
  • گوگل کروم: کلیدهای Ctrl+Shift+R را با هم فشار دهید (در رایانه‌های اپل مکینتاش کلید‌های ⌘-Shift-R)
  • اینترنت اکسپلورر/ Edge: کلید Ctrl را نگه‌دارید و روی دکمهٔ Refresh کلیک کنید، یا کلید‌های Ctrl-F5 را با هم فشار دهید
  • اپرا: Ctrl-F5 را بفشارید.
//<nowiki>


(function($){


/*
 ****************************************
 *** friendlytag.js: Tag module
 ****************************************
 * Mode of invocation:     Tab ("برچسب")
 * Active on:              Existing articles; file pages with a corresponding file
 *                         which is local (not on Commons); existing subpages of
 *                         {Iranpedia|Iranpedia talk}:Articles for creation;
 *                         all redirects
 * Config directives in:   FriendlyConfig
 */

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( ( mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 118 || /^Iranpedia( talk)?\:Articles for creation\//.exec(Morebits.pageNameNorm) ) && mw.config.get('wgCurRevisionId') ) {
		Twinkle.tag.mode = 'article';
		Twinkle.addPortletLink( Twinkle.tag.callback, "برچسب", "friendly-tag", "افزودن برچسب‌های نگهداری به مقاله" );
	}
};

Twinkle.tag.callback = function friendlytagCallback( uid ) {
	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( "راهنمای توینکل", "ip:TW/DOC#tag" );

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

	if (document.getElementsByClassName("patrollink").length) {
		form.append( {
			type: 'checkbox',
			list: [
				{
					label: 'Mark the page as patrolled',
					value: 'patrolPage',
					name: 'patrolPage',
					checked: Twinkle.getFriendlyPref('markTaggedPagesAsPatrolled')
				}
			]
		} );
	}

	switch( Twinkle.tag.mode ) {
		case 'article':
			tagMode = 'مقاله';
			Window.setTitle( "برچسب نگهداری مقاله" );

			form.append({
				type: 'select',
				name: 'sortorder',
				label: 'مشاهده فهرست:',
				tooltip: 'می‌توانید ترتیب نمایش پیش‌فرض را در ترجیحات توینکل تغییر دهید (ip:TWPREFS).',
				event: Twinkle.tag.updateSortOrder,
				list: [
					{ type: 'option', value: 'cat', label: 'بر پایه موضوع', selected: Twinkle.getFriendlyPref('tagArticleSortOrder') === 'cat' },
					{ type: 'option', value: 'alpha', label: 'به ترتیب الفبا', selected: Twinkle.getFriendlyPref('tagArticleSortOrder') === 'alpha' }
				]
			});

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

			form.append( {
					type: 'checkbox',
					list: [
						{
							label: 'جمع‌آوری در {{چند موضوع}} در صورت امکان',
							value: 'group',
							name: 'group',
							tooltip: 'در صورت افزودن بیشتر از سه برچسب که از {{چند موضوع}} پشتیبانی می‌کنند و انتخاب این گزینهتمام برچسب‌ها در الگوی {{چند موضوع}}نمایش داده می‌شوند.',
							checked: Twinkle.getFriendlyPref('groupByDefault')
						}
					]
				}
			);

			break;

		case 'file':
			tagMode = 'پرونده';
			Window.setTitle( "برچسب نگهداری پرونده" );

			// TODO: perhaps add custom tags TO list of checkboxes

			form.append({ type: 'header', label: 'برچسب‌های مشکلات حق نشر و منبع' });
			form.append({ type: 'checkbox', name: 'imageTags', list: Twinkle.tag.file.licenseList } );

			form.append({ type: 'header', label: 'برچسب‌های ویکی‌انبار' });
			form.append({ type: 'checkbox', name: 'imageTags', list: Twinkle.tag.file.commonsList } );

			form.append({ type: 'header', label: 'برچسب‌های تمیزکاری' } );
			form.append({ type: 'checkbox', name: 'imageTags', list: Twinkle.tag.file.cleanupList } );

			form.append({ type: 'header', label: 'برچسب‌های کیفیت نگاره' } );
			form.append({ type: 'checkbox', name: 'imageTags', list: Twinkle.tag.file.qualityList } );

			form.append({ type: 'header', label: 'برچسب‌های جایگزینی' });
			form.append({ type: 'checkbox', name: 'imageTags', list: Twinkle.tag.file.replacementList } );
			break;

		case 'redirect':
			tagMode = 'تغییر مسیر';
			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 });
			break;

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

	form.append( { type:'submit' } );

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

	if (Twinkle.tag.mode === "article") {
		// 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);
	}
};

Twinkle.tag.checkedTags = [];

Twinkle.tag.updateSortOrder = function(e) {
	var sortorder = e.target.value;

	Twinkle.tag.checkedTags = e.target.form.getChecked("articleTags");
	if (!Twinkle.tag.checkedTags) {
		Twinkle.tag.checkedTags = [];
	}
	
	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 "تمیزکاری":
				checkbox.subgroup = {
					name: 'cleanup',
					type: 'input',
					label: 'دلیل نیاز به تمیزکاری: ',
					tooltip: 'اجباری.',
					size: 35
				};
				break;
			case "ویراستاری":
				checkbox.subgroup = {
					name: 'copyEdit',
					type: 'input',
					label: '"این مقاله نیازمند ویراستاری است به دلیل..." ',
					tooltip: 'مانند "املا". اختیاری.',
					size: 35
				};
				break;
			case "کپی":
				checkbox.subgroup = {
					name: 'کپی',
					type: 'input',
					label: 'پیوند منبع: ',
					tooltip: 'اگر مشخص باشد.',
					size: 50
				};
				break;
			case "متخصص":
				checkbox.subgroup = {
					name: 'expertSubject',
					type: 'input',
					label: 'نام ویکی‌پروژه مرتبط: ',
					tooltip: 'اختیاری، نام ویکی‌پروژه‌ای که ممکن است متخصص مربوطه را معرفی کند، بنویسید. پیشوند ویکی‌پروژه را ننویسید.'
				};
				break;
			case "جهانی":
				checkbox.subgroup = {
					name: 'globalize',
					type: 'select',
					list: [
						{ label: "{{جهانی}}: article may not represent a worldwide view of the subject", value: "globalize" },
						{
							label: "زیرالگوهای منطقه‌ای {{جهانی}}",
							list: [
								{ label: "{{globalize/Australia}}: article deals primarily with the Australian viewpoint", value: "globalize/Australia" },
								{ label: "{{globalize/Canada}}: article deals primarily with the Canadian viewpoint", value: "globalize/Canada" },
								{ label: "{{globalize/China}}: article deals primarily with the Chinese viewpoint", value: "globalize/China" },
								{ label: "{{globalize/Common law}}: article deals primarily with the viewpoint of common law countries", value: "globalize/Common law" },
								{ label: "{{globalize/Eng}}: article deals primarily with the English-speaking viewpoint", value: "globalize/Eng" },
								{ label: "{{globalize/Europe}}: article deals primarily with the European viewpoint", value: "globalize/Europe" },
								{ label: "{{globalize/France}}: article deals primarily with the French viewpoint", value: "globalize/France" },
								{ label: "{{globalize/Germany}}: article deals primarily with the German viewpoint", value: "globalize/Germany" },
								{ label: "{{globalize/India}}: article deals primarily with the Indian viewpoint", value: "globalize/India" },
								{ label: "{{globalize/Middle East}}: article deals primarily with the Middle Eastern viewpoint", value: "globalize/Middle East" },
								{ label: "{{globalize/North America}}: article deals primarily with the North American viewpoint", value: "globalize/North America" },
								{ label: "{{globalize/Northern}}: article deals primarily with the northern hemisphere viewpoint", value: "globalize/Northern" },
								{ label: "{{globalize/Southern}}: article deals primarily with the southern hemisphere viewpoint", value: "globalize/Southern" },
								{ label: "{{globalize/South Africa}}: article deals primarily with the South African viewpoint", value: "globalize/South Africa" },
								{ label: "{{globalize/UK}}: article deals primarily with the British viewpoint", value: "globalize/UK" },
								{ label: "{{globalize/UK and Canada}}: article deals primarily with the British and Canadian viewpoints", value: "globalize/UK and Canada" },
								{ label: "{{globalize/US}}: article deals primarily with the USA viewpoint", value: "globalize/US" },
								{ label: "{{globalize/West}}: article deals primarily with the viewpoint of Western countries", value: "globalize/West" }
							]
						}
					]
				};
				break;
			case "ادغام":
			case "ادغام از":
			case "ادغام در":
				var otherTagName = "ادغام";
				switch (tag)
				{
					case "ادغام از":
						otherTagName = "ادغام در";
						break;
					case "ادغام در":
						otherTagName = "ادغام از";
						break;
				}
				checkbox.subgroup = [
					{
						name: 'mergeTarget',
						type: 'input',
						label: 'مقاله(های) دیگر: ',
						tooltip: 'If specifying multiple articles, separate them with pipe characters: Article one|Article two'
					},
					{
						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 === "ادغام در" ? 'مقاله دیگر' : 'این مقاله') + ' درج خواهد شد):',
						tooltip: 'اختیاری، ولی به شدت توصیه می‌شود. Leave blank if not wanted. تنها اگر نام یک مقاله درج شده باشد، امکان‌پذیر است.'
					});
				}
				break;
			case "ترجمه-نیاز":
			case "اصلاح ترجمه":
				checkbox.subgroup = [
					{
						name: 'translationLanguage',
						type: 'input',
						label: 'زبان مقاله (اگر معلوم باشد): ',
						tooltip: 'Consider looking at [[ip:LRC]] for help. If listing the article at PNT, please try to avoid leaving this box blank, unless you are completely unsure.'
					}
				];
				if (tag === "ترجمه-نیاز") {
					checkbox.subgroup.push({
						name: 'translationNotify',
						type: 'checkbox',
						list: [
							{
								label: 'آگاه‌سازی نویسنده مقاله',
								checked: true,
								tooltip: "Places {{uw-notenglish}} on the creator's talk page."
							}
						]
					});
				}
				checkbox.subgroup.push({
					name: 'translationPostAtPNT',
					type: 'checkbox',
					list: [
						{
							label: 'List this article at Iranpedia:Pages needing translation into English (PNT)',
							checked: true
						}
					]
				});
				checkbox.subgroup.push({
					name: 'translationComments',
					type: 'textarea',
					label: 'Additional comments to post at PNT',
					tooltip: 'Optional, and only relevant if "List this article ..." above is checked.'
				});
				break;
			case "سرشناسی":
				checkbox.subgroup = {
					name: 'notability',
					type: 'select',
					list: [
						{ label: "{{سرشناسی}}: موضوع مقاله ممکن است معیارهای عمومی سرشناسی را نداشته باشد", value: "none" },
						{ label: "{{سرشناسی|دانشگاهیان}}: راهنمای سرشناسی برای دانشگاهیان", value: "دانشگاهیان" },
						{ label: "{{سرشناسی|افراد}}: راهنمای سرشناسی برای افراد", value: "افراد" },
						{ label: "{{سرشناسی|کتاب}}: راهنمای سرشناسی برای کتاب‌ها", value: "کتاب" },
						{ label: "{{سرشناسی|شرکت}}: راهنمای سرشناسی برای شرکت‌ها و سازمان‌ها", value: "شرکت" },
						{ label: "{{سرشناسی|رویداد}}: راهنمای سرشناسی برای رویدادها", value: "رویداد" },
						{ label: "{{سرشناسی|فیلم}}: راهنمای سرشناسی برای فیلم‌ها", value: "فیلم" },
						{ label: "{{سرشنناسی|مکان}}: راهنمای سرشناسی برای مکان‌ها", value: "مکان" },
						{ label: "{{سرشناسی|موسیقی}}: راهنمای سرشناسی برای موسیقی", value: "موسیقی" },
						{ label: "{{سرشناسی|فضا}}: راهنمای سرشناسی برای اجرام آسمانی", value: "فضا" },
						{ label: "{{سرشناسی|عددها}}: راهنمای سرشناسی برای عددها", value: "عددها" },
						{ label: "{{سرشناسی|محصول}}: راهنمای سرشناسی برای محصولات", value: "محصول" },
						{ label: "{{سرشناسی|ورزش}}: راهنمای سرشناسی برای ورزش‌ها و ورزشکاران", value: "ورزش" },
						{ label: "{{سرشناسی|وب}}: راهنمای سرشناسی برای وب", value: "وب" }
					]
				};
				break;
			default:
				break;
		}
		return checkbox;
	};

	// categorical sort order
	if (sortorder === "cat") {
		// 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];
				checkboxes.push(makeCheckbox(tag, description));
			});
			subdiv.append({
				type: "checkbox",
				name: "articleTags",
				list: checkboxes
			});
		};

		var i = 0;
		// 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 ($.isArray(content)) {
				doCategoryCheckboxes(subdiv, content);
			} else {
				$.each(content, function(subtitle, subcontent) {
					subdiv.append({ type: "div", label: [ Morebits.htmlNode("b", subtitle) ] });
					doCategoryCheckboxes(subdiv, subcontent);
				});
			}
		});
	}
	// alphabetical sort order
	else {
		var checkboxes = [];
		$.each(Twinkle.tag.article.tags, function(tag, description) {
			checkboxes.push(makeCheckbox(tag, description));
		});
		container.append({
			type: "checkbox",
			name: "articleTags",
			list: checkboxes
		});
	}

	// append any custom tags
	if (Twinkle.getFriendlyPref('customTagList').length) {
		container.append({ type: 'header', label: 'برچسب‌های دلخواه' });
		container.append({ type: 'checkbox', name: 'articleTags', list: Twinkle.getFriendlyPref('customTagList') });
	}

	var $workarea = $(e.target.form).find("div#tagWorkArea");
	var rendered = container.render();
	$workarea.empty().append(rendered);

	// 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' });

	// add a link to each template's description page
	$.each(Morebits.quickForm.getElements(e.target.form, "articleTags"), function(index, checkbox) {
		var $checkbox = $(checkbox);
		var link = Morebits.htmlNode("a", ">");
		link.setAttribute("class", "tag-template-link");
		link.setAttribute("href", mw.util.getUrl("Template:" + 
			Morebits.string.toUpperCaseFirstChar($checkbox.val())));
		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 = {
	"تبلیغات": "ساختار مقاله مشابه مطالب تبلیغاتی است",
	"all plot": "article is almost entirely a plot summary",
	"خودزندگی‌نامه": "مقاله یک خودزندگی‌نامه است و شاید بی‌طرفانه نوشته نشده باشد",
	"BLP sources": "BLP article needs additional sources for verification",
	"BLP unsourced": "BLP article has no sources at all (use BLP PROD instead for new articles)",
	"citation style": "article has unclear or inconsistent inline citations",
	"تمیزکاری": "مقاله نیاز به تمیزکاری دارد",
	"بازسازماندهی": "ممکن است که مقاله نیاز به سازماندهی مجدد داشته باشد تا مطابق با معیارهای طرح‌بندی ایران‌پدیا باشد",
	"close paraphrasing": "article contains close paraphrasing of a non-free copyrighted source",
	"تعارض منافع": "سازنده یا مشارکت‌کننده عمده مقاله ممکن است دارای تعارض منافع باشد",
	"condense": "article may have too many section headers dividing up its content",
	"گیج‌کننده": "مقاله ممکن است گیج‌کننده یا نامفهوم باشد",
	"زمینه": "مقاله زمینهٔ کافی را فراهم نمی‌کند",
	"ویراستاری": "مقاله نیاز به ویراستاری املا، نگارش، لحن یا موارد دیگر دارد",
	"کپی": "به نظر می‌رسد که این مقاله رونوشتی از یک منبع باشد",
	"بن‌بست": "این مقاله به هیچ مقاله‌ای پیوند ندارد",
	"درستی": "در درستی مقاله، اختلاف نظر وجود دارد",
	"انشا مانند": "این مقاله شبیه توصیه‌ها یا نظرات شخصی نوشته شده‌است",
	"گسترش از زبان": "مقاله را می‌توان با ترجمه از یک ایران‌پدیای دیگر گسترش داد",
	"متخصص": "این مقاله نیازمند بازبینی توسط یک متخصص است",
	"پیوندهای بیرونی": "پیوندهای بیرونی مقاله ممکن است سیاست‌ها و معیارهای محتوایی را رعایت نکنند",
	"هواداران": "مقاله به صورت هوادارانه نوشته شده‌است",
	"fiction": "article fails to distinguish between fact and fiction",
	"globalize": "article may not represent a worldwide view of the subject",
	"GOCEinuse": "article is currently undergoing a major copy edit by the Guild of Copy Editors",
	"کلک": "مقاله ممکن است کلک‌زنی باشد",
	"بهبود رده‌ها": "مقاله شاید به رده‌های بیشتری نیاز داشته باشد",
	"in-universe": "article subject is fictional and needs rewriting from a non-fictional perspective",
	"incoherent": "article is incoherent or very hard to understand",
	"in use": "article is undergoing a major edit for a short while",
	"فاقد بخش آغازین": "این مقاله، بخش آغازین ندارد و باید نوشته شود",
	"بازنویسی بخش آغازین": "بخش آغازین مقاله باید بازنویسی شود تا با معیارها همخوانی داشته باشد",
	"بخش آغازین بلند": "بخش آغازین مقاله، بلند است و باید کوتاه‌تر شود",
	"بخش آغازین کوتاه": "بخش آغازین مقاله، کوتاه است و باید گسترش یابد",
	"linkrot": "article uses bare URLs for references, which are prone to link rot",
	"آموزشی": "مقاله شبیه کتابچه راهنما یا خودآموز نوشته شده‌است",
	"ادغام": "مقاله باید با مقاله‌ای دیگر ادغام شود",
	"ادغام از": "مقاله دیگری باید در این مقاله ادغام شود",
	"ادغام در": "این مقاله باید در مقاله دیگری ادغام شود",
	"سیستم متریک-نیاز": "مقاله به شدت از یکاهای اندازه‌گیری غیر استاندارد استفاده می‌کند",
	"پانوشت بیشتر": "مقاله چند منبع دارد، ولی ارجاع درون‌متنی کافی ندارد",
	"new unreviewed article": "mark article for later review",
	"انتشار خبری": "مقاله شبیه انتشار خبری خوانده می‌شود",
	"بدون پانویس": "مقاله منبع دارد، ولی ارجاع درون‌متنی ندارد",
	"غیر-آزاد": "این مقاله ممکن است استفاده بیش از اندازه یا نامناسب از محتوای غیر آزاد داشته باشد",
	"سرشناسی": "موضوع مقاله ممکن است معیارهای سرشناسی را برآورده نکند",
	"ترجمه-نیاز": "مقاله به یک زبان دیگر نوشته شده و باید ترجمه شود",
	"one source": "article relies largely or entirely upon a single source",
	"original research": "article has original research or unverified claims",
	"یتیم": "هیچ مقاله‌ای به این مقاله پیوند ندارد",
	"overcoverage": "article has an extensive bias or disproportional coverage towards one or more specific regions",
	"overlinked": "article may have too many duplicate and/or irrelevant links",
	"overly detailed": "article contains an excessive amount of intricate detail",
	"واژه نامناسب": "مقاله ممکن است شامل واژه‌های نامناسب باشد که اطلاعاتی در مورد موضوع نمی‌دهد و طرفدارانه است",
	"plot": "plot summary in article is too long",
	"طرفداری": "مقاله از دیدگاه بی‌طرف نوشته نشده‌است",
	"primary sources": "article relies too heavily on primary sources, and needs secondary sources",
	"prose": "article is in a list format that may be better presented using prose",
	"تازه‌گرایی": "مقاله به سوی رویدادهای اخیر انحراف دارد",
	"ref improve": "article needs additional references or sources for verification",
	"اصلاح ترجمه": "مقاله به صورت نامناسبی ترجمه شده و نیازمند بهبود است",
	"بخش‌بندی": "مقاله باید به چند بخش تقسیم شود",
	"self-published": "article may contain improper references to self-published sources",
	"فنی": "مقاله ممکن است برای فهم بسیاری از خوانندگان، بیش از حد فنی باشد",
	"tense": "article is written in an incorrect tense",
	"third-party": "article relies too heavily on affiliated sources, and needs third-party sources",
	"لحن": "لحن مقاله نامناسب است",
	"too few opinions": "article may not include all significant viewpoints",
	"رده‌بندی‌نشده": "مقاله رده‌بندی نشده‌است",
	"under construction": "article is currently in the middle of an expansion or major revamping",
	"underlinked": "article may require additional wikilinks",
	"undue": "article lends undue weight to certain aspects of the subject but not others",
	"منبع": "مقاله هیچ منبعی ندارد",
	"unreliable sources": "article's references may not be reliable sources",
	"نیازمند به‌روزرسانی": "مقاله نیازمند افزودن اطلاعات به روز است",
	"طولانی": "مقاله بیش از حد طولانی است",
	"طفره‌آمیز": "این مقاله آکنده از الفاظ طفره‌آمیز است"
};

// 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 = {
	"برچسب‌های تمیزکاری و نگهداری": {
		"تمیزکاری عمومی": [
			"تمیزکاری",  // has a subgroup with text input
			"ویراستاری"  // has a subgroup with text input
		],
		"محتوای نامناسب": [
			"close paraphrasing",
			"کپی",  // has a subgroup with text input
			"پیوندهای بیرونی",
			"غیر-آزاد"
		],
		"ساختار، قالب و بخش آغازین": [
			"بازسازماندهی",
			"condense",
			"فاقد بخش آغازین",
			"بازنویسی بخش آغازین",
			"بخش آغازین بلند",
			"بخش آغازین کوتاه",
			"بخش‌بندی",
			"طولانی"
		],
		"Fiction-related cleanup": [
			"all plot",
			"fiction",
			"in-universe",
			"plot"
		]
	},
	"موارد محتوایی عمومی": {
		"اهمیت و سرشناسی": [
			"سرشناسی"  // has a subgroup with subcategories
		],
		"سبک نوشتار": [
			"تبلیغات",
			"انشا مانند",
			"هواداران",
			"آموزشی",
			"انتشار خبری",
			"prose",
			"فنی",
			"tense",
			"لحن"
		],
		"Sense (or lack thereof)": [
			"گیج‌کننده",
			"incoherent"
		],
		"اطلاعات و جزئیات": [
			"زمینه",
			"متخصص",
			"سیستم متریک-نیاز",
			"overly detailed",
			"undue"
		],
		"Timeliness": [
			"نیازمند به‌روزرسانی"
		],
		"بی‌طرفی، اریبی و دقت": [
			"خودزندگی‌نامه",
			"تعارض منافع",
			"درستی",
			"کلک",
			"جهانی",  // has a subgroup with subcategories
			"overcoverage",
			"واژه نامناسب",
			"طرفداری",
			"تازه‌گرایی",
			"too few opinions",
			"طفره‌آمیز"
		],
		"تأییدپذیری و منبع": [
			"BLP sources",
			"BLP unsourced",
			"one source",
			"original research",
			"primary sources",
			"ref improve",
			"self-published",
			"third-party",
			"منبع",
			"unreliable sources"
		]
	},
	"Specific content issues": {
		"Language": [
			"ترجمه-نیاز",  // has a subgroup with several options
			"اصلاح ترجمه",  // has a subgroup with several options
			"گسترش از زبان"
		],
		"پیونددهی": [
			"بن‌بست",
			"یتیم",
			"overlinked",
			"underlinked"
		],
		"روش منبع‌دهی": [
			"citation style",
			"linkrot",
			"پانوشت بیشتر",
			"بدون پانویس"
		],
		"رده‌ها": [
			"بهبود رده‌ها",
			"رده‌بندی‌نشده"
		]
	},
	"ادغام": [  // these three have a subgroup with several options
		"ادغام",
		"ادغام از",
		"ادغام در"
	],
	"Informational": [
		"GOCEinuse",
		"in use",
		"new unreviewed article",
		"under construction"
	]
};

// Tags for REDIRECTS start here

Twinkle.tag.spellingList = [
	{
		label: '{{R from abbreviation}}: تغییرمسیر از یک عنوان مخفف',
		value: 'R from abbreviation'
	},
	{
		label: '{{R to list entry}}: redirect to a \"list of minor entities\"-type article which contains brief descriptions of subjects not notable enough to have separate articles',
		value: 'R to list entry'
	},
	{
		label: '{{تغییرمسیر به بخش}}: similar to {{R to list entry}}, but when list is organized in sections, such as list of characters in a fictional universe.',
		value: 'R to section'
	},
	{
		label: '{{R from misspelling}}: redirect from a misspelling or typographical error',
		value: 'R from misspelling'
	},
	{
		label: '{{R from alternative spelling}}: redirect from a title with a different spelling',
		value: 'R from alternative spelling'
	},
	{
		label: '{{R from plural}}: redirect from a plural word to the singular equivalent',
		value: 'R from plural'
	},
	{
		label: '{{R from related word}}: redirect from a related word',
		value: 'R from related word'
	},
	{
		label: '{{R with possibilities}}: redirect from a more specific title to a more general, less detailed article, hence something which can and should be expanded',
		value: 'R with possibilities'
	},
	{
		label: '{{R from member}}: redirect from a member of a group to a related topic such as the group, organization, or team that he or she belongs to',
		value: 'R from member'
	},
	{
		label: '{{R from other capitalisation}}: redirect from a title with another method of capitalisation',
		value: 'R from other capitalisation'
	}
];

Twinkle.tag.alternativeList = [
	{
		label: '{{R from alternative name}}: redirect from a title that is another name, a pseudonym, a nickname, or a synonym',
		value: 'R from alternative name'
	},
	{
		label: '{{R from full name}}: redirect from a title that is a complete or more complete name',
		value: 'R from full name'
	},
	{
		label: '{{R from surname}}: redirect from a title that is a surname',
		value: 'R from surname'
	},
	{
		label: '{{R from historic name}}: redirect from another name with a significant historic past as a region, state, city or such, but which is no longer known by that title or name',
		value: 'R from historic name'
	},
	{
		label: '{{R from phrase}}: redirect from a phrase to a more general relevant article covering the topic',
		value: 'R from phrase'
	},
	{
		label: '{{R from scientific name}}: redirect from the scientific name to the common name',
		value: 'R from scientific name'
	},
	{
		label: '{{R to scientific name}}: redirect from the common name to the scientific name',
		value: 'R to scientific name'
	},
	{
		label: '{{R from name and country}}: redirect from the specific name to the briefer name',
		value: 'R from name and country'
	},
	{
		label: '{{R from alternative language}}: redirect from an English name to a name in another language, or vice-versa',
		value: 'R from alternative language'
	},
	{
		label: '{{R from ASCII}}: redirect from a title in basic ASCII to the formal article title, with differences that are not diacritical marks (accents, umlauts, etc.)',
		value: 'R from ASCII'
	},
	{
		label: '{{R from title without diacritics}}: redirect to the article title with diacritical marks (accents, umlauts, etc.)',
		value: 'R from title without diacritics'
	}
];

Twinkle.tag.administrativeList = [
	{
		label: '{{تغییرمسیر حاصل از ادغام}}: تغییرمسیر از یک صفحه ادغام شده به منظور نگهداری از تاریخچه‌ ویرایشش',
		value: 'R from merge'
	},
	{
		label: '{{R to disambiguation page}}: تغییر مسیر به یک صفحه ابهام‌زدایی',
		value: 'R to disambiguation page'
	},
	{
		label: '{{R from duplicated article}}: تغییر مسیر به یک مقاله مشابه برای نگه داشتن تاریخچه ویرایش آن',
		value: 'R from duplicated article'
	},
	{
		label: '{{R to decade}}: تغییر مسیر از یک سال به مقاله دهه',
		value: 'R to decade'
	},
	{
		label: '{{R from shortcut}}: تغییر مسیر از یک میان‌بر ایران‌پدیا',
		value: 'R from shortcut'
	},
	{
		label: '{{R from CamelCase}}: redirect from a CamelCase title',
		value: 'R from CamelCase'
	},
	{
		label: '{{R from EXIF}}: redirect of a wikilink created from JPEG EXIF information (i.e. the \"metadata\" section on some image description pages)',
		value: 'R from EXIF'
	},
	{
		label: '{{R from school}}: redirect from a school article that had very little information',
		value: 'R from school'
	}
];

// 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: 'Non-free reduced' }
];

Twinkle.tag.file.commonsList = [
	{ label: '{{انتقال به ویکی‌انبار}}: free media that should be copied to Commons', value: 'Copy to Commons' },
	{ label: '{{به ویکی‌انبار انتقال ندهید}} (PD issue): file is PD in the US but not in country of origin', value: 'Do not move to Commons' },
	{ label: '{{به ویکی‌انبار انتقال ندهید}} (other reason)', value: 'Do not move to Commons_reason' },
	{ label: '{{Keep local}}: request to keep local copy of a Commons file', value: 'Keep local' },
	{ label: '{{موجود در انبار}}: file has been copied to Commons', value: 'جا:ncd' }
];

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' },
	{ label: '{{Cleanup SVG}}: SVG needing code and/or appearance cleanup', value: 'Cleanup SVG' },
	{ label: '{{ClearType}}: image (not screenshot) with ClearType anti-aliasing', value: 'ClearType' },
	{ label: '{{واترمارک تصویر}}: 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 [[ip:FMV]]', value: 'Rename media' },
	{ label: '{{Should be PNG}}: GIF or JPEG should be lossless', value: 'Should be PNG' },
	{
		label: '{{باید اس‌وی‌جی باشد}}: PNG, GIF or JPEG should be vector graphics', value: 'Should be SVG',
		subgroup: {
			name: 'svgCategory',
			type: 'select',
			list: [
				{ label: '{{باید اس‌وی‌جی باشد|other}}', value: 'other' },
				{ label: '{{باید اس‌وی‌جی باشد|alphabet}}: character images, font examples, etc.', value: 'alphabet' },
				{ label: '{{باید اس‌وی‌جی باشد|chemical}}: chemical diagrams, etc.', value: 'chemical' },
				{ label: '{{باید اس‌وی‌جی باشد|circuit}}: electronic circuit diagrams, etc.', value: 'circuit' },
				{ label: '{{باید اس‌وی‌جی باشد|coat of arms}}: coats of arms', value: 'coat of arms' },
				{ label: '{{باید اس‌وی‌جی باشد|diagram}}: diagrams that do not fit any other subcategory', value: 'diagram' },
				{ label: '{{باید اس‌وی‌جی باشد|emblem}}: emblems, free/libre logos, insignias, etc.', value: 'emblem' },
				{ label: '{{باید اس‌وی‌جی باشد|fair use}}: fair-use images, fair-use logos', value: 'fair use' },
				{ label: '{{باید اس‌وی‌جی باشد|flag}}: flags', value: 'flag' },
				{ label: '{{باید اس‌وی‌جی باشد|graph}}: visual plots of data', value: 'graph' },
				{ label: '{{باید اس‌وی‌جی باشد|logo}}: logos', value: 'logo' },
				{ label: '{{باید اس‌وی‌جی باشد|map}}: maps', value: 'map' },
				{ label: '{{باید اس‌وی‌جی باشد|music}}: musical scales, notes, etc.', value: 'music' },
				{ label: '{{باید اس‌وی‌جی باشد|physical}}: "realistic" images of physical objects, people, etc.', value: 'physical' },
				{ label: '{{باید اس‌وی‌جی باشد|symbol}}: miscellaneous symbols, icons, etc.', value: 'symbol' }
			]
		}
	},
	{ label: '{{باید متن باشد}}: image should be represented as text, tables, or math markup', value: 'Should be text' },
	{ label: '{{Split media}}: there are two different images in the upload log which need to be split', value: 'Split media' }
];

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' },
	{ label: '{{Image-underexposure}}', value: 'Image-underexposure' },
	{ label: '{{Low quality chem}}: disputed chemical structures', value: 'Low quality chem' }
];

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: '{{SVG version available}}', value: 'SVG version available' }
];


// Contains those article tags that *do not* work inside {{multiple issues}}.
Twinkle.tag.multipleIssuesExceptions = [
	'copypaste',
	'گسترش از زبان',
	'GOCEinuse',
	'بهبود رده‌ها',
	'in use',
	'ادغام',
	'ادغام از',
	'ادغام در',
	'new unreviewed article',
	'ترجمه-نیاز',
	'اصلاح ترجمه',
	'رده‌بندی‌نشده',
	'under construction'
];


Twinkle.tag.callbacks = {
	main: function( pageobj ) {
		var params = pageobj.getCallbackParameters(),
		    tagRe, tagText = '', summaryText = 'افزودن برچسب ',
		    tags = [], groupableTags = [], i, totalTags;

		// Remove tags that become superfluous with this action
		var pageText = pageobj.getPageText().replace(/\{\{\s*([Nn]ew unreviewed article|[Uu]nreviewed|[Uu]serspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/g, "");

		var addTag = function friendlytagAddTag( tagIndex, tagName ) {
			var currentTag = "";
			if( tagName === 'رده‌بندی‌نشده' || tagName === 'بهبود رده‌ها' ) {
				pageText += '\n\n{{' + tagName +
					'|date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}';
			} else {
				if( tagName === 'جهانی' ) {
					currentTag += '{{' + params.tagParameters.globalize;
				} else {
					currentTag += ( Twinkle.tag.mode === 'redirect' ? '\n' : '' ) + '{{' + tagName;
				}

				if( tagName === 'سرشناسی' && params.tagParameters.notability !== 'none' ) {
					currentTag += '|' + params.tagParameters.notability;
				}

				// prompt for other parameters, based on the tag
				switch( tagName ) {
					case 'تمیزکاری':
						if (params.tagParameters.cleanup) {
							currentTag += '|دلیل=' + params.tagParameters.cleanup;
						}
						break;
					case 'ویراستاری':
						if (params.tagParameters.copyEdit) {
							currentTag += '|for=' + params.tagParameters.copyEdit;
						}
						break;
					case 'کپی':
						if (params.tagParameters.copypaste) {
							currentTag += '|url=' + params.tagParameters.copypaste;
						}
						break;
					case 'گسترش از زبان':
						currentTag += '|topic=';
						var langcode = prompt('لطفاً کد زبان ویکی دیگر را بنویسید مانند. "fr").  \n' +
							"این اطلاعات اجباری است. برای توقف زدن برچسب {{گسترش از زبان}} درخواست را لغو کنید.", "");
						if (langcode === null || langcode === "") {
							Morebits.status.warn("آگاه‌سازی", "زدن برچسب {{گسترش از زبان}} توسط کاربر متوقف شد");
							return true;  // continue to next tag
						} else {
							currentTag += '|langcode=' + langcode;
						}
						var otherart = prompt('لطفاً نام مقاله در ویکی دیگر را بنویسید (بدون پیشوند میان‌ویکی).  \n' +
							"این اطلاعات اختیاری است. برای توقف زدن برچسب {{گسترش از زبان}} درخواست را لغو کنید.", "");
						if (otherart === null) {
							Morebits.status.warn("آگاه‌سازی", "زدن برچسب {{گسترش از زبان}} توسط کاربر متوقف شد");
							return true;  // continue to next tag
						} else {
							currentTag += '|otherarticle=' + otherart;
						}
						break;
					case 'متخصص':
						if (params.tagParameters.expertSubject) {
							currentTag += '|1=' + params.tagParameters.expertSubject;
						}
						break;
					case 'انتشار خبری':
						currentTag += '|1=article';
						break;
					case 'ترجمه-نیاز':
					case 'اصلاح ترجمه':
						if (params.translationLanguage) {
							currentTag += '|1=' + params.translationLanguage;
						}
						if (params.translationPostAtPNT) {
							currentTag += '|listed=yes';
						}
						break;
					case 'ادغام':
					case 'ادغام در':
					case 'ادغام از':
						if (params.mergeTarget) {
							// 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 === "ادغام در" ? params.mergeTarget : mw.config.get('wgTitle'));
									// nonDiscussArticle is the article which won't have the discussion
									params.nonDiscussArticle = (tagName === "ادغام در" ? mw.config.get('wgTitle') : params.mergeTarget);
									params.talkDiscussionTitle = 'پیشنهاد ادغام با ' + params.nonDiscussArticle;
								}
								currentTag += '|discuss=Talk:' + params.discussArticle + '#' + params.talkDiscussionTitle;
							}
						}
						break;
					default:
						break;
				}

				currentTag += (Twinkle.tag.mode === 'redirect') ? '}}' : '|date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}\n';
				tagText += currentTag;
			}

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

			summaryText += ' {{[[';
			if( tagName === 'جهانی' ) {
				summaryText += "Template:" + params.tagParameters.globalize + '|' + params.tagParameters.globalize;
			} else {
				summaryText += (tagName.indexOf(":") !== -1 ? tagName : ("Template:" + tagName + "|" + tagName));
			}
			summaryText += ']]}}';
		};

		if( Twinkle.tag.mode !== 'redirect' ) {
			// Check for preexisting tags and separate tags into groupable and non-groupable arrays
			for( i = 0; i < params.tags.length; i++ ) {
				tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\})|\\|\\s*' + params.tags[i] + '\\s*=[a-z ]+\\d+)', 'im' );
				if( !tagRe.exec( pageText ) ) {
					if( Twinkle.tag.multipleIssuesExceptions.indexOf(params.tags[i]) === -1 ) {
						groupableTags = groupableTags.concat( params.tags[i] );
					} else {
						tags = tags.concat( params.tags[i] );
					}
				} else {
					Morebits.status.warn( 'Info', 'برچسب {{' + params.tags[i] +
						'}} از قبل روی مقاله وجود دارد...لغو درخواست' );
					// don't do anything else with merge tags
					if (params.tags[i] === "ادغام" || params.tags[i] === "ادغام از" ||
						params.tags[i] === "ادغام در") {
						params.mergeTarget = params.mergeReason = params.mergeTagOther = false;
					}
				}
			}

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

			if( ( miTest || miOldStyleTest ) && groupableTags.length > 0 ) {
				Morebits.status.info( 'Info', 'افزودن برچسب‌ها درون برچسب {{چند موضوع}}' );

				groupableTags.sort();
				tagText = "";

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

				summaryText += ' (دارای {{[[الگو:چند موضوع|چند موضوع]]}})';
				if( tags.length > 0 ) {
					summaryText += '، و';
				}

				if( miOldStyleTest ) {
					// convert tags from old-style to new-style
					var split = miOldStyleTest[2].split("|");
					$.each(split, function(index, val) {
						split[index] = val.replace("=", "|date=").trim();
					});
					pageText = pageText.replace(miOldStyleRegex, "{{$1|\n{{" + split.join("}}\n{{") + "}}\n" + tagText + "}}\n");
				} else {
					var miRegex = new RegExp("(\\{\\{\\s*" + miTest[1] + "\\s*(?:\\|(?:\\{\\{[^{}]*\\}\\}|[^{}])*)?)\\}\\}\\s*", "im");
					pageText = pageText.replace(miRegex, "$1" + tagText + "}}\n");
				}
				tagText = "";
			} else if( params.group && groupableTags.length >= 3 ) {
				Morebits.status.info( 'Info', 'گروه‌بندی برچسب‌ها در {{چند موضوع}}' );

				groupableTags.sort();
				tagText += '{{چند موضوع|\n';

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

				summaryText += ' (دارای {{[[الگو:چند موضوع|چند موضوع]]}})';
				if( tags.length > 0 ) {
					summaryText += '، و';
				}
				tagText += '}}\n';
			} else {
				tags = tags.concat( groupableTags );
			}
		} else {
			// Redirect tagging: Check for pre-existing tags
			for( i = 0; i < params.tags.length; i++ ) {
				tagRe = new RegExp( '(\\{\\{' + params.tags[i] + '(\\||\\}\\}))', 'im' );
				if( !tagRe.exec( pageText ) ) {
					tags = tags.concat( params.tags[i] );
				} else {
					Morebits.status.warn( 'Info', 'برچسب {{' + params.tags[i] +
						'}} از قبل روی مقاله وجود دارد...لغو درخواست' );
				}
			}
		}

		tags.sort();
		totalTags = tags.length;
		$.each(tags, addTag);

		if( Twinkle.tag.mode === 'redirect' ) {
			pageText += tagText;
		} else {
			// smartly insert the new tags after any hatnotes. Regex is a bit more
			// complicated than it'd need to be, to allow templates as parameters,
			// and to handle whitespace properly.
			pageText = pageText.replace(/^\s*(?:((?:\s*\{\{\s*(?:about|correct title|dablink|distinguish|for|other\s?(?:hurricaneuses|people|persons|places|uses(?:of)?)|redirect(?:-acronym)?|see\s?(?:also|wiktionary)|selfref|the)\d*\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\})+(?:\s*\n)?)\s*)?/i,
				"$1" + tagText);
		}
		summaryText += ' به ' + tagMode;

		// 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.getFriendlyPref('watchTaggedPages'));
		pageobj.setMinorEdit(Twinkle.getFriendlyPref('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.nonDiscussArticle + "]] ==\n\n";
				talkpageText += params.mergeReason.trim() + " ~~~~";

				var talkpage = new Morebits.wiki.page("بحث:" + params.discussArticle, "درج دلیل در صفحه بحث");
				talkpage.setAppendText(talkpageText);
				talkpage.setEditSummary('پیشنهاد ادغام [[' + params.nonDiscussArticle + ']] ' +
					(tags.indexOf("ادغام") !== -1 ? 'با' : 'در') + ' [[' + params.discussArticle + ']]' +
					Twinkle.getPref('summaryAd'));
				talkpage.setWatchlist(Twinkle.getFriendlyPref('watchMergeDiscussions'));
				talkpage.setCreateOption('recreate');
				talkpage.append();
			}
			if (params.mergeTagOther) {
				// tag the target page if requested
				var otherTagName = "ادغام";
				if (tags.indexOf("ادغام از") !== -1) {
					otherTagName = "ادغام در";
				} else if (tags.indexOf("ادغام در") !== -1) {
					otherTagName = "ادغام از";
				}
				var newParams = {
					tags: [otherTagName],
					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.main);
			}

			// post at ip:PNT for {{not English}} and {{rough translation}} tag
			if (params.translationPostAtPNT) {
				var pntPage = new Morebits.wiki.page('Iranpedia:Pages needing translation into English',
					"Listing article at Iranpedia:Pages needing translation into English");
				pntPage.setFollowRedirect(true);
				pntPage.setCallbackParameters({
					template: params.tags.indexOf("اصلاح ترجمه") !== -1 ? "duflu" : "needtrans",
					lang: params.translationLanguage,
					reason: params.translationComments
				});
				pntPage.load(Twinkle.tag.callbacks.translationListPage);
			}
			if (params.translationNotify) {
				pageobj.lookupCreator(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('User talk:' + 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();
		}
	},

	translationListPage: 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 = "Translation cleanup requested on ";
		} else {
			text = old_text.replace(/\n+(==\s?Translated pages that could still use some cleanup\s?==)/,
				"\n\n" + templateText + "\n\n$1");
			summary = "Translation" + (params.lang ? (" از  " + params.lang) : "") + " requested on ";
		}

		if (text === old_text) {
			statelem.error('failed to find target spot for the discussion');
			return;
		}
		pageobj.setPageText(text);
		pageobj.setEditSummary(summary + " [[" + Morebits.pageNameNorm + "]]" + Twinkle.getPref('summaryAd'));
		pageobj.setCreateOption('recreate');
		pageobj.save();
	},

	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", "جا: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, "");
				}
				if (tag === "SVG version available") {
					text = text.replace(/\{\{((convert to |convertto|should be |shouldbe|to)?svg|badpng|vectorize)[^}]*\}\}/gi, "");
				}

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

				var input;
				switch (tag) {
					case "جا:ncd":
						/* falls through */
					case "Keep local":
						input = prompt( "{{" + (tag === "جا:ncd" ? "Now Commons" : tag) +
							"}} - نام تصویر را در ویکی‌انبار ذکر نمائید (در صورتی که با نام تصویر موجود در ویکی‌فا تفاوت دارد)، بدون پیشوند پرونده یا File:", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += '|1=' + input;
						}
						break;
					case "Rename media":
						input = prompt( "{{Rename media}} - Enter the new name for the image (optional):", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|1=" + input;
						}
						input = prompt( "{{Rename media}} - Enter the reason for the rename (optional):", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|2=" + input;
						}
						break;
					case "Cleanup image":
						/* falls through */
					case "Cleanup SVG":
						input = prompt( "{{" + tag + "}} - Enter the reason for cleanup (required). To skip the tag, click Cancel:", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|1=" + input;
						}
						break;
					case "Image-Poor-Quality":
						input = prompt( "{{Image-Poor-Quality}} - Enter the reason why this image is so bad (required). To skip the tag, click Cancel:", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|1=" + input;
						}
						break;
					case "Low quality chem":
						input = prompt( "{{Low quality chem}} - Enter the reason why the diagram is disputed (required). To skip the tag, click Cancel:", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|1=" + input;
						}
						break;
					case "PNG version available":
						/* falls through */
					case "SVG version available":
						/* falls through */
					case "Obsolete":
						/* falls through */
					case "Duplicate":
						input = prompt( "{{" + tag + "}} - Enter the name of the file which replaces this one (required). To skip the tag, click Cancel:", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|1=" + input;
						}
						break;
					case "Do not move to Commons_reason":
						input = prompt( "{{به ویکی‌انبار انتقال ندهید}} - Enter the reason why this image should not be moved to Commons (required). To skip the tag, click Cancel:", "" );
						if (input === null) {
							return true;  // continue
						} else if (input !== "") {
							currentTag += "|دلیل=" + input;
						}
						break;
					case "Non-free reduced":
						//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 "انتقال به انبار":
						currentTag += "|human=" + mw.config.get("wgUserName");
						break;
					default:
						break;  // don't care
				}

				if (tag === "باید اس‌وی‌جی باشد") {
					currentTag += "|" + params.svgSubcategory;
				}

				currentTag += "}}\n";

				tagtext += currentTag;
				summary += "{{" + tag + "}}, ";

				return true;  // continue
			});

			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.getFriendlyPref('watchTaggedPages'));
		pageobj.setMinorEdit(Twinkle.getFriendlyPref('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;
	}

	switch (Twinkle.tag.mode) {
		case 'article':
			params.tags = form.getChecked( 'articleTags' );
			params.group = form.group.checked;
			params.tagParameters = {
				cleanup: form["articleTags.cleanup"] ? form["articleTags.cleanup"].value : null,
				copyEdit: form["articleTags.copyEdit"] ? form["articleTags.copyEdit"].value : null,
				copypaste: form["articleTags.copypaste"] ? form["articleTags.copypaste"].value : null,
				expertSubject: form["articleTags.expertSubject"] ? form["articleTags.expertSubject"].value : null,
				globalize: form["articleTags.globalize"] ? form["articleTags.globalize"].value : null,
				notability: form["articleTags.notability"] ? form["articleTags.notability"].value : null
			};
			// common to {{merge}}, {{merge from}}, {{merge to}}
			params.mergeTarget = form["articleTags.mergeTarget"] ? form["articleTags.mergeTarget"].value : null;
			params.mergeReason = form["articleTags.mergeReason"] ? form["articleTags.mergeReason"].value : null;
			params.mergeTagOther = form["articleTags.mergeTagOther"] ? form["articleTags.mergeTagOther"].checked : false;
			// common to {{not English}}, {{rough translation}}
			params.translationLanguage = form["articleTags.translationLanguage"] ? form["articleTags.translationLanguage"].value : null;
			params.translationNotify = form["articleTags.translationNotify"] ? form["articleTags.translationNotify"].checked : null;
			params.translationPostAtPNT = form["articleTags.translationPostAtPNT"] ? form["articleTags.translationPostAtPNT"].checked : null;
			params.translationComments = form["articleTags.translationComments"] ? form["articleTags.translationComments"].value : null;
			break;
		case 'file':
			params.svgSubcategory = form["imageTags.svgCategory"] ? form["imageTags.svgCategory"].value : null;
			params.tags = form.getChecked( 'imageTags' );
			break;
		case 'redirect':
			params.tags = form.getChecked( 'redirectTags' );
			break;
		default:
			alert("Twinkle.tag: unknown mode " + Twinkle.tag.mode);
			break;
	}

	// form validation
	if( !params.tags.length ) {
		alert( 'باید حداقل یک برچسب را انتخاب کنید!' );
		return;
	}
	if( ((params.tags.indexOf("ادغام") !== -1) + (params.tags.indexOf("ادغام از") !== -1) +
		(params.tags.indexOf("ادغام در") !== -1)) > 1 ) {
		alert( 'لطفاً تنها یکی از {{ادغام}}، {{ادغام از}} و {{ادغام در}} را انتخاب کنید. If several merges are required, use {{ادغام}} and separate the article names with pipes (although in this case Twinkle cannot tag the other articles automatically).' );
		return;
	}
	if( (params.tags.indexOf("not English") !== -1) && (params.tags.indexOf("rough translation") !== -1) ) {
		alert( 'Please select only one of {{not English}} and {{rough translation}}.' );
		return;
	}
	if( (params.mergeTagOther || params.mergeReason) && params.mergeTarget.indexOf('|') !== -1 ) {
		alert( 'Tagging multiple articles in a merge, and starting a discussion for multiple articles, is not supported at the moment. Please turn off "tag other article", and/or clear out the "reason" box, and try again.' );
		return;
	}
	if( params.tags.indexOf('cleanup') !== -1 && params.tagParameters.cleanup.trim && params.tagParameters.cleanup.trim() === "") {
		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 iranpedia_page = new Morebits.wiki.page(Morebits.pageNameNorm, "در حال برچسب زدن به " + Twinkle.tag.mode);
	iranpedia_page.setCallbackParameters(params);
	switch (Twinkle.tag.mode) {
		case 'article':
			/* falls through */
		case 'redirect':
			iranpedia_page.load(Twinkle.tag.callbacks.main);
			return;
		case 'file':
			iranpedia_page.load(Twinkle.tag.callbacks.file);
			return;
		default:
			alert("Twinkle.tag: unknown mode " + Twinkle.tag.mode);
			break;
	}
};
})(jQuery);


//</nowiki>