Module:User:Erutuon/requests

local m_languages = require("Module:languages")

local export = {}

function export.contents(frame) local items = {} local no_catfix = false local valid_category = false if type(frame) == "table" then items.pagename = mw.title.getCurrentTitle.text elseif type(frame) == "string" then items.pagename = frame frame = mw.getCurrentFrame end local en = m_languages.getByCode("en") local categories = { {			regex = "^Requests concerning (.+)$", request_sortkey = "requests", this_request_in_all_languages = "Requests by language", not_hidden_category = true },		{			regex = "^Requests concerning (.+) entries$", request_sortkey = "requests", this_request_in_all_languages = "Requests by language", not_hidden_category = true },		{			regex = "^Requests for etymologies in (.+) entries$", request_sortkey = "etymology", template_name = "rfe", this_request_in_all_languages = "Requests for etymologies by language", },		{			regex = "^Requests for expansion of etymologies in (.+) entries$", request_sortkey = "etymology2", template_name = "etystub", this_request_in_all_languages = "Requests for expansion of etymologies by language", },		{			regex = "^Requests for pronunciation in (.+) entries$", request_sortkey = "pronunciation", template_name = "rfp", this_request_in_all_languages = "Requests for pronunciation by language", },		{			regex = "^Requests for audio pronunciation in (.+) entries$", request_sortkey = "audio pronunciation", template_name = "rfap", this_request_in_all_languages = "Requests for audio pronunciation by language", },		{			regex = "^Requests for definitions in (.+) entries$", request_sortkey = "definition", template_name = "rfdef", this_request_in_all_languages = "Requests for definitions by language", },		{			regex = "^Requests for clarification of definitions in (.+) entries$", request_sortkey = "definition2", template_name = "sense stub", this_request_in_all_languages = "Requests for clarification of definitions by language", },		{			regex = "^Requests for inflections in (.+) entries$", request_sortkey = "inflection", template_name = "rfinfl", this_request_in_all_languages = "Requests for inflections by language", },		{			regex = "^Requests for inflections in (.+) adjective entries$", request_sortkey = "adjective", template_name = "rfinfl", template_syntax = "", one_level_above_in_the_same_language = "Requests for inflections in entries", this_request_in_all_languages = "Requests for inflections of adjectives by language", },		{			regex = "^Requests for inflections in (.+) noun entries$", request_sortkey = "noun", template_name = "rfinfl", template_syntax = "", one_level_above_in_the_same_language = "Requests for inflections in entries", this_request_in_all_languages = "Requests for inflections of nouns by language", },		{			regex = "^Requests for inflections in (.+) participle entries$", request_sortkey = "noun", template_name = "rfinfl", template_syntax = "", one_level_above_in_the_same_language = "Requests for inflections in entries", this_request_in_all_languages = "Requests for inflections of participles by language", },		{			regex = "^Requests for inflections in (.+) pronoun entries$", request_sortkey = "pronoun", template_name = "rfinfl", template_syntax = "", one_level_above_in_the_same_language = "Requests for inflections in entries", this_request_in_all_languages = "Requests for inflections of pronouns by language", },		{			regex = "^Requests for inflections in (.+) verb entries$", request_sortkey = "verb", template_name = "rfinfl", template_syntax = "", one_level_above_in_the_same_language = "Requests for inflections in entries", this_request_in_all_languages = "Requests for inflections of verbs by language", },		{			regex = "^Requests for example sentences in (.+)$", request_sortkey = "example", template_name = "rfex", this_request_in_all_languages = "Requests for example sentences by language", },		{			regex = "^Requests for quotations in (.+)$", request_sortkey = "quotation", template_name = "rfquote", this_request_in_all_languages = "Requests for quotations by language", },		{			regex = "^Requests for translations into (.+)$", request_sortkey = "translation", template_name = "t-needed", this_request_in_all_languages = "Requests for translations by language", catfix_lang = en, },		{			regex = "^Requests for review of (.+) translations$", request_sortkey = "translation2", template_name = "t-check", template_syntax = "", template_description = "", this_request_in_all_languages = "Requests for review of translations by language", catfix_lang = en, },		{			regex = "^Requests for images in (.+) entries$", request_sortkey = "image", template_name = "rfi", this_request_in_all_languages = "Requests for images by language", },		{			regex = "^Requests for references for (.+) terms$", request_sortkey = "reference", this_request_in_all_languages = "Requests for references by language", },		{			regex = "^Requests for references for etymologies in (.+) entries$", request_sortkey = "reference2", template_name = "rfv-etymology", one_level_above_in_the_same_language = "Requests for references for terms", this_request_in_all_languages = "Requests for references for etymologies by language", },		{			regex = "^Requests for references for pronunciations in (.+) entries$", request_sortkey = "reference3", template_name = "rfv-pronunciation", one_level_above_in_the_same_language = "Requests for references for terms", this_request_in_all_languages = "Requests for references for pronunciations by language", },		{			regex = "^Requests for attention concerning (.+)$", request_sortkey = "attention", template_name = "attention", template_description = "This template does not generate any text in entries.", this_request_in_all_languages = "Requests for attention by language", no_catfix = true, },		{			regex = "^Requests for cleanup in (.+) entries$", request_sortkey = "cleanup", this_request_in_all_languages = "Requests for cleanup by language", },		{			regex = "^Requests for verification in (.+) entries$", request_sortkey = "verification", template_name = "rfv", this_request_in_all_languages = "Requests for verification by language", },		{			regex = "^Requests for attention in etymologies in (.+) entries$", request_sortkey = "attention etymology", this_request_in_all_languages = "Requests for attention in etymologies by language", },	}	if mw.ustring.find(items.pagename, "^Requests .* by language$") then for i, category in pairs(categories) do if items.pagename == category.this_request_in_all_languages then valid_category = true items.request_sortkey = category.request_sortkey end end else for i, category in pairs(categories) do			if mw.ustring.find(items.pagename, category.regex) then valid_category = true for key, value in pairs(category) do					items[key] = value end if not category.not_hidden_category then items.hidden_category = "__HIDDENCAT__" end end end end

if not valid_category then error("Category name is not recognized.") end if items.regex then items.language_name = mw.ustring.match(items.pagename, items.regex) items.language_object = m_languages.getByCanonicalName(items.language_name) or error ('The category title contains an invalid language name, "' .. language_name .. '". Choose a canonical name from the data modules of Module:languages.') items.language_code = items.language_object:getCode end items.edit_link = "{| class='wikitable noprint plainlinks' style='float: right'\n| Edit category data\n|}" items.description = ("\nThis category contains .")

if items.template_name then if items.template_syntax then items.template_syntax_with_language_code = items.template_syntax else items.template_syntax_with_language_code = ("") end

items.full_text_about_the_template = "\n" .. ("To make this request, in this specific language, use this code in the entry (see also the documentation at Template:):\n\n ")

if items.template_description then items.full_text_about_the_template = items.full_text_about_the_template .. " " .. items.template_description else items.full_text_about_the_template = items.full_text_about_the_template .. "\nIt results in the message below:\n\n<<>>" end end if not items.one_level_above_in_the_same_language then if mw.ustring.find(items.pagename, "^Requests .* by language$") then items.one_level_above_in_the_same_language = "Request subcategories by language" elseif mw.ustring.find(items.pagename, "^Requests concerning .*") then items.one_level_above_in_the_same_language = " entry maintenance" else items.one_level_above_in_the_same_language = "Requests concerning " end end

if items.one_level_above_in_the_same_language then items.one_level_above_in_the_same_language_text = "" end if items.regex then items.this_request_in_all_languages_text = ("") end if items.catfix_lang or ( not items.no_catfix and items.language_object ) then items.catfix = require("Module:utilities").catfix(items.catfix_lang or items.language_object) end items.pagename = mw.ustring.gsub(items.pagename, "Requests", "requests") result = require("Module:table").compressSparseArray{ items.hidden_category, items.catfix, items.edit_link, items.description, items.full_text_about_the_template, items.one_level_above_in_the_same_language_text, items.this_request_in_all_languages_text } result = table.concat(result, "\n") while result:find("{{{") do		result = mw.ustring.gsub(			result,			"{{{([^%}%{]+)}}}",			function(item)				if items[item] then					if type(items[item]) == "string" or type(items[item]) == "number" then						return items[item]					else						error('The item "{{{' .. item .. '}}}" is a ' .. type(item) .. ' and can\'t be concatenated. (Pagename: ' .. items.pagename .. '.)')					end				else					error('The item "' .. item .. '" was not found in the "items" table. (Pagename: ' .. items.pagename .. '.)')				end			end		) end

result = mw.ustring.gsub(		result,		"<<([^>]+)>>",		function (template_code)			return frame:preprocess(template_code)		end	) return result end

function export.test(frame) if type(frame) ~= "table" then error('The function "' .. test '" requires a frame object as argument.') end local pagenames = {} local results = {} for i, item in pairs(frame.args) do		mw.text.trim(item) table.insert(pagenames, item) item = export.contents(item) item = frame:extensionTag{ name = "syntaxhighlight", content = item, args = { lang = "html" } } table.insert(results, item) end local output = {} table.insert(output, '{| class="wikitable"') for i, result in pairs(results) do table.insert(output, '\n|-\n| ' .. pagenames[i] .. ' || ' .. result) end table.insert(output, '\n|}') return table.concat(output) end

return export