Module:request-forum

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

local export = {}

local standard_namespaces = {
	[""] = true,
	["Citations"] = true,
	["Reconstruction"] = true,
	["Transwiki"] = true,
}

local Sinitic_scripts = {
	["Bopo"] = true, -- Zhuyin
	["Hani"] = true, -- Han
	["Hans"] = true, -- Han (simplified)
	["Hant"] = true, -- Han (traditional)
	["Jpan"] = true, -- Japanese (general)
	["Hira"] = true, -- Hiragana
	["Kana"] = true, -- Katakana
	["Kore"] = true, -- Korean (general)
	["Hang"] = true, -- Hangul
	["Jurc"] = true, -- Jurchen
	["Kitl"] = true, -- Khitan large script
	["Kits"] = true, -- Khitan small script
	["Nshu"] = true, -- Nüshu
	["Shui"] = true, -- Sui
	["Tang"] = true, -- Tangut
}

local function subforum(lang_code, type)
	local namespace = mw.title.getCurrentTitle().nsText

	 -- RFDs of articles in nonstandard namespaces go straight to [[WT:RFDO]] without having their language code checked.
	 -- This branch is only used by [[Template:rfd]] because the other RFD templates ([[Template:rfd-sense]], [[Template:rfd-redundant]]) semantically presuppose the target to be a lingual element.
	if type == "deletion" and not standard_namespaces[namespace] then
		return "Wiktionary:Requests for " .. type .. "/Others"
	elseif namespace == "Reconstruction" then
		-- There is no 'Requests for verification/Reconstruction'; everything vectors to RFDR.
		return "Wiktionary:Requests for deletion/Reconstruction"
	end
	local lang = require("Module:languages").getByCode(lang_code, 1) -- print error if invalid code
	if lang:inFamily("gmw-ang") and not lang:inFamily("crp") and lang:getFullCode() ~= "ang" then
		return "Wiktionary:Requests for " .. type .. "/English"
	elseif lang:inFamily("jpx", "qfa-kor", "sit-sba") or Sinitic_scripts[lang:findBestScript(mw.title.getCurrentTitle().subpageText):getCode()] then
		return "Wiktionary:Requests for " .. type .. "/CJK"
	elseif lang:inFamily("itc") then
		return "Wiktionary:Requests for " .. type .. "/Italic"
	else
		return "Wiktionary:Requests for " .. type .. "/Non-English"
	end
end

function export.rfv(frame)
	return subforum(frame.args[1], "verification")
end

function export.rfd(frame)
	return subforum(frame.args[1], "deletion")
end

return export