Module:R:it:DiPI

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

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


local export = {}

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

	local links = {}
	for i, term in ipairs(args[1]) do
		if term == "+" then
			term = mw.title.getCurrentTitle().text
		end
		local alt = args.alt[i] or term
		local normalized_term = term:gsub("ì", "í"):gsub("ù", "ú")
		local url = "http://www.dipionline.it/dizionario/ricerca?lemma=" .. mw.uri.encode(normalized_term)
		table.insert(links, "[" .. url .. " " .. alt .. "]")
	end
	local joined_links = table.concat(links, ", ")
	return joined_links .. " in [[w:Luciano Canepari|Luciano Canepari]], ''Dizionario di Pronuncia Italiana (DiPI)''"
end

return export