Модул:nyms

Пређи на навигацију Пређи на претрагу
Документација модула[прикажи] [уреди] [историја] [освежи]

This provides the backend for {{synonyms}}, {{antonyms}}, {{hypernyms}}, {{hyponyms}}, {{meronyms}}, {{holonyms}}, {{troponyms}}, {{coordinate terms}}, {{perfectives}} and {{imperfectives}}.

local export = {}

local m_languages = require("Модул:languages")
local m_links = require("Модул:links")
local m_qual = require("Модул:qualifier")

function export.nyms(frame)
	local params = {
		[1] = {required = true, default = "und"},
		[2] = {list = true, allow_holes = true, required = true},
		
		["alt"] = {list = true, allow_holes = true},
		["tr"] = {list = true, allow_holes = true},
		["q"] = {list = true, allow_holes = true}
	}
	
	local args = require("Модул: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)
	
	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 "и" or "") ..
		":</span> " .. table.concat(args[2], ", ") .. "</span>"
end


return export