Module:R:it:DOP

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

This module implements the reference template {{R:it:DOP}}.


local export = {}

function export.create(frame) 
	 local params = {
		["lid"] = {list = true, allow_holes = true, required = true},
		["lemma"] = {list = true, allow_holes = true, default = mw.title.getCurrentTitle().text},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)

	local links = {}
	for i, id in ipairs(args["lid"]) do
		local lemma = args.lemma[i] or "+"
		if lemma == "+" then
			lemma = mw.title.getCurrentTitle().text
		end
		-- URL's generated by searching have a separate numeric rID= in them but that isn't necessary to get to the lemma.
		local url = "https://dizionario.rai.it/p.aspx?nID=lemma&lID=" .. id
		table.insert(links, "[" .. url .. " " .. lemma .. "]")
	end
	local joined_links = table.concat(links, ", ")
	return joined_links .. " in [[w:Bruno Migliorini|Bruno Migliorini]] et al., ''Dizionario d'ortografia e di pronunzia'', Rai Eri, 2007"
end

return export