Module:User:Erutuon/requests

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This was used to work on a new version of Module:category tree/requests.

Requests for inflections in Votic verb entries
__HIDDENCAT__
<span id="catfix" style="display:none;" class="CATFIX-Votic"><span class="Latn" lang="vot">&nbsp;</span></span>
{| class='wikitable noprint plainlinks' style='float: right'
| '''[https://en.wiktionary.org/w/index.php?title=Module:category_tree/requests&action=edit Edit category data]'''
|}

This category contains '''requests for inflections in Votic verb entries'''.

To make this request, in this specific language, use this code in the entry (see also the documentation at [[Template:rfinfl]]):

<pre>{{rfinfl|vot|verb}}</pre>
It results in the message below:

<p style="font-size: smaller">This verb needs an [[:Category:Votic verb inflection-table templates|inflection-table template]].</p>
[[Category:Requests for inflections in Votic entries|verb]]
[[Category:Requests for inflections of verbs by language|Votic]]
Requests for etymologies in English entries
__HIDDENCAT__
<span id="catfix" style="display:none;" class="CATFIX-English"><span class="None" lang="en">&nbsp;</span></span>
{| class='wikitable noprint plainlinks' style='float: right'
| '''[https://en.wiktionary.org/w/index.php?title=Module:category_tree/requests&action=edit Edit category data]'''
|}

This category contains '''requests for etymologies in English entries'''.

To make this request, in this specific language, use this code in the entry (see also the documentation at [[Template:rfe]]):

<pre>{{rfe|en}}</pre>
It results in the message below:

<span class="maintenance-line" style="color: #777777;">(This [[Wiktionary:Etymology|etymology]] is missing or incomplete. Please add to it, or discuss it at the [[Wiktionary:Etymology scriptorium#|Etymology scriptorium]].)</span>
[[Category:Requests concerning English|etymology]]
[[Category:Requests for etymologies by language|English]]
Requests for attention concerning French
__HIDDENCAT__
{| class='wikitable noprint plainlinks' style='float: right'
| '''[https://en.wiktionary.org/w/index.php?title=Module:category_tree/requests&action=edit Edit category data]'''
|}

This category contains '''requests for attention concerning French'''.

To make this request, in this specific language, use this code in the entry (see also the documentation at [[Template:attention]]):

<pre>{{attention|fr}}</pre> This template does not generate any text in entries.
[[Category:Requests concerning French|attention]]
[[Category:Requests for attention by language|French]]
Requests for expansion of etymologies in English entries
__HIDDENCAT__
<span id="catfix" style="display:none;" class="CATFIX-English"><span class="None" lang="en">&nbsp;</span></span>
{| class='wikitable noprint plainlinks' style='float: right'
| '''[https://en.wiktionary.org/w/index.php?title=Module:category_tree/requests&action=edit Edit category data]'''
|}

This category contains '''requests for expansion of etymologies in English entries'''.

To make this request, in this specific language, use this code in the entry (see also the documentation at [[Template:etystub]]):

<pre>{{etystub|en}}</pre>
It results in the message below:

<span class="maintenance-line"><i>This [[Wiktionary:Etymology|etymology]] is incomplete. You can help Wiktionary by elaborating on the origins of this term. </i></span>
[[Category:Requests concerning English|etymology2]]
[[Category:Requests for expansion of etymologies by language|English]]
Requests for images by language
{| class='wikitable noprint plainlinks' style='float: right'
| '''[https://en.wiktionary.org/w/index.php?title=Module:category_tree/requests&action=edit Edit category data]'''
|}

This category contains '''requests for images by language'''.
[[Category:Request subcategories by language|image]]

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 = "{{rfinfl|{{{language_code}}}|adjective}}",
			one_level_above_in_the_same_language = "Requests for inflections in {{{language_name}}} 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 = "{{rfinfl|{{{language_code}}}|noun}}",
			one_level_above_in_the_same_language = "Requests for inflections in {{{language_name}}} 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 = "{{rfinfl|{{{language_code}}}|participle}}",
			one_level_above_in_the_same_language = "Requests for inflections in {{{language_name}}} 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 = "{{rfinfl|{{{language_code}}}|noun}}",
			one_level_above_in_the_same_language = "Requests for inflections in {{{language_name}}} 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 = "{{rfinfl|{{{language_code}}}|verb}}",
			one_level_above_in_the_same_language = "Requests for inflections in {{{language_name}}} 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 = "{{t-check|{{{language_code}}}|example}}",
			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 {{{language_name}}} 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 {{{language_name}}} 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| '''[https://en.wiktionary.org/w/index.php?title=Module:category_tree/requests&action=edit Edit category data]'''\n|}"
	
	items.description = ("\nThis category contains '''{{{pagename}}}'''.")

	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 = ("{{{{{template_name}}}|{{{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:{{{template_name}}}]]):\n\n<pre>{{{template_syntax_with_language_code}}}</pre>")

		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<<{{{template_syntax_with_language_code}}}>>"
		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 = "{{{language_name}}} entry maintenance"
		else
			items.one_level_above_in_the_same_language = "Requests concerning {{{language_name}}}"
		end
	end

	if items.one_level_above_in_the_same_language then
		items.one_level_above_in_the_same_language_text = "[[Category:{{{one_level_above_in_the_same_language}}}|{{{request_sortkey}}}]]"
	end
	
	if items.regex then
		items.this_request_in_all_languages_text = ("[[Category:{{{this_request_in_all_languages}}}|{{{language_name}}}]]")
	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| [[:Category:' .. pagenames[i] .. '|' .. pagenames[i] .. ']] || ' .. result)
	end
	
	table.insert(output, '\n|}')
	
	return table.concat(output)
end

return export