Module:User:Isomorphyc/etymology-draft/templates

local export = {}

function export.etyl(frame) local params = { [1] = {required = true, default = "und"}, [2] = {},		["sort"] = {}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local source = args[1] local lang = args[2] local sort_key = args["sort"] -- Empty language means English, but "-" means no language. Yes, confusing... if not lang then lang = "en" elseif lang == "-" then lang = nil end if lang then lang = require("Module:User:Isomorphyc/languages-draft").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.") end source = require("Module:User:Isomorphyc/languages-draft").getByCode(source) or		require("Module:etymology languages").getByCode(source) or		require("Module:families").getByCode(source) or error("The language, family or etymology language code \"" .. source .. "\" is not valid.") if lang and (lang:getCode == "la" or lang:getCode == "nl") then require("Module:debug").track("etyl/" .. lang:getCode) require("Module:debug").track("etyl/" .. lang:getCode .. "/" .. source:getCode) end return require("Module:User:Isomorphyc/etymology-draft").format_etyl(lang, source, sort_key) end

function export.cognate(frame) local params = { [1] = {required = true, default = "und"}, [2] = {},		[3] = {alias_of = "alt"}, [4] = {alias_of = "gloss"}, ["alt"] = {}, ["g"] = {}, ["gloss"] = {}, ["id"] = {}, ["lit"] = {}, ["pos"] = {}, ["t"] = {alias_of = "gloss"}, ["tr"] = {}, ["pr"] = {}, ["sc"] = {}, ["sort"] = {}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local source = args[1] local sc = args["sc"] source = require("Module:User:Isomorphyc/languages-draft").getByCode(source) or		require("Module:etymology languages").getByCode(source) or		require("Module:families").getByCode(source) or error("The language, family or etymology language code \"" .. source .. "\" is not valid.") sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil) return require("Module:User:Isomorphyc/etymology-draft").format_cognate(		{lang = source, sc = sc, term = args[2], alt = args["alt"], id = args["id"], genders = {args["g"]}, tr = args["tr"], pr = args["pr"], gloss = args["gloss"], pos = args["pos"], lit = args["lit"]},		args["sort"]) end

function export.derived(frame) local params = { [1] = {required = true, default = "und"}, [2] = {required = true, default = "und"}, [3] = {},		[4] = {alias_of = "alt"}, [5] = {alias_of = "gloss"}, ["alt"] = {}, ["g"] = {}, ["gloss"] = {}, ["id"] = {}, ["lit"] = {}, ["pos"] = {}, ["t"] = {alias_of = "gloss"}, ["tr"] = {}, ["pr"] = {}, ["sc"] = {}, ["sort"] = {}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local lang = args[1] local source = args[2] local sc = args["sc"] lang = require("Module:User:Isomorphyc/languages-draft").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.") source = require("Module:User:Isomorphyc/languages-draft").getByCode(source) or		require("Module:etymology languages").getByCode(source) or		require("Module:families").getByCode(source) or error("The language, family or etymology language code \"" .. source .. "\" is not valid.") sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil) return require("Module:User:Isomorphyc/etymology-draft").format_derived(		lang, 		{lang = source, sc = sc, term = args[3], alt = args["alt"], id = args["id"], genders = {args["g"]}, tr = args["tr"], pr = args["pr"], gloss = args["gloss"], pos = args["pos"], lit = args["lit"]},		args["sort"]) end

function export.inherited(frame) local params = { [1] = {required = true, default = "und"}, [2] = {required = true, default = "und"}, [3] = {},		[4] = {alias_of = "alt"}, [5] = {alias_of = "gloss"}, ["alt"] = {}, ["g"] = {}, ["gloss"] = {}, ["id"] = {}, ["lit"] = {}, ["pos"] = {}, ["t"] = {alias_of = "gloss"}, ["tr"] = {}, ["pr"] = {}, ["sc"] = {}, ["sort"] = {}, }	local args = require("Module:parameters").process(frame:getParent.args, params) local lang = args[1] local source = args[2] local sc = args["sc"] lang = require("Module:User:Isomorphyc/languages-draft").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.") source = require("Module:User:Isomorphyc/languages-draft").getByCode(source) or		require("Module:etymology languages").getByCode(source) or error("The language or etymology language code \"" .. source .. "\" is not valid.") sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil) return require("Module:User:Isomorphyc/etymology-draft").format_inherited(		lang,		{lang = source, sc = sc, term = args[3], alt = args["alt"], id = args["id"], genders = {args["g"]}, tr = args["tr"], pr = args["pr"], gloss = args["gloss"], pos = args["pos"], lit = args["lit"]},		args["sort"]) end

function export.borrowed(frame) local learned = frame.args["learned"]; if not learned or learned == "" then learned = false else learned = true end local params = { [1] = {required = true, default = "und"}, [2] = {required = true, default = "und"}, [3] = {},		[4] = {alias_of = "alt"}, [5] = {alias_of = "gloss"}, ["alt"] = {}, ["g"] = {}, ["gloss"] = {}, ["id"] = {}, ["lit"] = {}, ["pos"] = {}, ["t"] = {alias_of = "gloss"}, ["tr"] = {}, ["pr"] = {}, ["sc"] = {}, ["nocap"] = {type = "boolean"}, ["notext"] = {type = "boolean"}, ["sort"] = {}, }	local compat = false if frame:getParent.args["lang"] then compat = true end if compat then require("Module:debug").track("borrowing/lang") params["lang"] = table.remove(params, 1) end local args = require("Module:parameters").process(frame:getParent.args, params) local lang = args[compat and "lang" or 1] local source = args[compat and 1 or 2] local sc = args["sc"] lang = require("Module:User:Isomorphyc/languages-draft").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.") source = require("Module:User:Isomorphyc/languages-draft").getByCode(source) or		require("Module:etymology languages").getByCode(source) or		require("Module:families").getByCode(source) or error("The language, family or etymology language code \"" .. source .. "\" is not valid.") sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil) return require("Module:User:Isomorphyc/etymology-draft").format_borrowed(		lang,		{lang = source, sc = sc, term = args[compat and 2 or 3], alt = args["alt"], id = args["id"], genders = {args["g"]}, tr = args["tr"], pr = args["pr"], gloss = args["gloss"], pos = args["pos"], lit = args["lit"]},		args["sort"], args["nocap"], args["notext"], learned) end

function export.calque(frame) local params = { [1] = {required = true, default = "und"}, [2] = {required = true, default = "und"}, [3] = {},		[4] = {alias_of = "alt"}, [5] = {alias_of = "gloss"}, ["alt"] = {}, ["g"] = {}, ["gloss"] = {}, ["id"] = {}, ["lit"] = {}, ["pos"] = {}, ["t"] = {alias_of = "gloss"}, ["tr"] = {}, ["pr"] = {}, ["sort"] = {}, ["nocap"] = {type = "boolean"}, ["notext"] = {type = "boolean"}, }	local compat_lang = false local compat_etyl = false if frame:getParent.args["lang"] then compat_lang = true compat_etyl = true elseif frame:getParent.args["etyl lang"] then compat_etyl = true end if compat_etyl then require("Module:debug").track("calque/etyl") params["etyl lang"] = {required = true, default = "und"} params["etyl term"] = {} params["etyl t"] = {} params["etyl tr"] = {} params[2] = {list = true, allow_holes = true} params[3] = nil params[4] = nil params[5] = nil params["alt"] = {list = true, allow_holes = true} params["g"] = nil params["gloss"] = {list = true, allow_holes = true} params["id"] = nil params["lit"] = nil params["pos"] = {list = true, allow_holes = true} params["t"] = {alias_of = "gloss", list = true, allow_holes = true} params["tr"] = {list = true, allow_holes = true} params["pr"] = {list = true, allow_holes = true} end if compat_lang then require("Module:debug").track("calque/lang") params["lang"] = table.remove(params, 1) end local args = require("Module:parameters").process(frame:getParent.args, params) local lang = args[compat_lang and "lang" or 1] local source = args[compat_etyl and "etyl lang" or 2] lang = require("Module:User:Isomorphyc/languages-draft").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.") source = require("Module:User:Isomorphyc/languages-draft").getByCode(source) or		require("Module:etymology languages").getByCode(source) or error("The language or etymology language code \"" .. source .. "\" is not valid.") local parts = {} if compat_etyl then for i = 1, math.max(args[compat_lang and 1 or 2].maxindex, args["alt"].maxindex, args["gloss"].maxindex, args["tr"].maxindex, args["pr"].maxindex) do			table.insert(parts, {				term = args[compat_lang and 1 or 2][i],				alt = args["alt"][i],				tr = args["tr"][i],				pr = args["pr"][i],				gloss = args["gloss"][i],				pos = args["pos"][i],			}) end end return require("Module:User:Isomorphyc/etymology-draft").calque(		lang,		{lang = source, term = args[compat_etyl and "etyl term" or 3], alt = not compat_etyl and args[4] or nil, tr = args[compat_etyl and "etyl tr" or "tr"], pr = args[compat_etyl and "etyl pr" or "pr"], gloss = args[compat_etyl and "etyl t" or 5]},		parts, args["sort"], args["nocap"], args["notext"]) end

return export