Module:User:Ungoliant MMDCCLXIV

This is a private module sandbox of Ungoliant MMDCCLXIV, for his own experimentation. Items in this module may be added and removed at Ungoliant MMDCCLXIV's discretion; do not rely on this module's stability.


local export = {}

local m_languages = require("Module:languages")
local m_links = require("Module:links")
local m_qual = require("Module:qualifier")

function export.nyms(frame)
	local params = {
		[1] = {required = true, default = "und"},
		[2] = {list = true, allow_holes = true, required = false},
		
		["alt"] = {list = true, allow_holes = true},
		["tr"] = {list = true, allow_holes = true},
		["q"] = {list = true, allow_holes = true}
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local nym_type = frame.args[1]
	local lang = m_languages.getByCode(args[1]) or m_languages.err(args[1], 1)
	
	local maxindex = math.max(args[2].maxindex, args["alt"].maxindex, args["tr"].maxindex)
	
	if maxindex < 1 then
		
		return "<span class=\"nyms " .. nym_type .. "\"><span class=\"defdate\">" .. 
			mw.getContentLanguage():ucfirst(nym_type) ..
			":</span> " .. "<small>[please add!]</small>" ..
			"[[Category:" .. lang:getCanonicalName() .. " " .. nym_type .. " requests]]" ..
			"</span>"
		
	else
	
		for i = 1, maxindex do
			args[2][i] = m_links.full_link{ lang = lang, term = args[2][i], alt = args["alt"][i], tr = args["tr"][i] }
			if args["q"][i] then
				args[2][i] = args[2][i] .. " " .. m_qual.format_qualifier({args["q"][i]})
			end
		end
		
		return "<span class=\"nyms " .. nym_type .. "\"><span class=\"defdate\">" .. 
			mw.getContentLanguage():ucfirst(nym_type) .. (maxindex > 1 and "s" or "") ..
			":</span> " .. table.concat(args[2], ", ") .. "</span>"
		
	end
end


return export