มอดูล:etymology/templates/cognate

จาก วิกิพจนานุกรม พจนานุกรมเสรี
local export = {}

local m_internal = require("Module:etymology/templates/internal")

function export.cognate(frame)
	local parent_args = frame:getParent().args
	
	if parent_args.gloss then
		require("Module:debug/track")("cognate/gloss param")
	end
	
	local params = {
		[1] = true,
		[2] = false,
		
		["alt"] = {aliases = { 3 }},
		["id"] = false,
		["lit"] = false,
		["pos"] = false,
		["t"] = {aliases = { 4, "gloss" }},
		["tr"] = false,
		["ts"] = false,
		["sc"] = false,
		
		["sort"] = false,
		["conj"] = false,
	}
	
	args = require("Module:parameters/lite").process(parent_args, params)
	args["g"] = require("Module:parameters/lite/list")(parent_args, "g")
	
	local source, sources = m_internal.fetch_source_or_sources(args[1], 1)
	local sc = m_internal.fetch_script(args["sc"], "sc")

	local terminfo = {
		lang = source,
		sc = sc,
		term = args[2],
		alt = args["alt"],
		id = args["id"],
		genders = args["g"],
		tr = args["tr"],
		ts = args["ts"],
		gloss = args["t"],
		pos = args["pos"],
		lit = args["lit"]
	}

	if sources then
		return require("Module:etymology/multi").format_multi_cognate(sources, terminfo, args.sort, args.conj)
	else
		return require("Module:etymology").format_cognate(terminfo, args.sort)
	end
end


function export.noncognate(frame)
	return export.cognate(frame)
end

return export