Modul:form of/templates

Vikilug‘atdan olingan

Bu modul uchun Modul:form of/templates/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}

function export.template_tags(frame)
	local iparams = {
		[1] = {list = true, required = true},
		["cat"] = {},
	}
	
	local iargs = require("Module:parameters").process(frame.args, iparams)
	
	local params = {
		[1] = {required = true},
		[2] = {},
		[3] = {alias_of = "gloss"},
		
		["gloss"] = {},
		["id"] = {},
		["tili"] = {required = true},
		["nodot"] = {type = "boolean"},  -- does nothing right now, but used in existing entries
		["sc"] = {},
		["tr"] = {},
	}
	
	if iargs["cat"] then
		params["nocat"] = {type = "boolean"}
		params["sort"] = {}
	end
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local tili = args["tili"] or "und"
	local sc = args["sc"]
	
	tili = require("Module:tili").getByCode(tili) or error("The language code \"" .. tili .. "\" is not valid.")
	sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
	
	if #iargs[1] == 1 and iargs[1][1] == "f" then
		require("Module:debug").track("feminine of/" .. tili:getCode())
	end
	
	local ret = require("Module:form of").tagged_inflections(iargs[1], args[1] or "term", args[2], tili, sc, args["id"], {gloss = args["gloss"], tr = args["tr"]})
	
	if iargs["cat"] then
		if args["nocat"] then
			require("Module:debug").track("form of/" .. table.concat(iargs[1], "-") .. "/nocat")
		else
			require("Module:debug").track("form of/" .. table.concat(iargs[1], "-") .. "/cat")
			ret = ret .. require("Module:utilities").format_categories({tili:getCanonicalName() .. " " .. iargs["cat"]}, tili, args["sort"])
		end
	end
	
	return ret
end

function export.form_of_t(frame)
	local params = {
		[1] = {required = true},
		[2] = {required = true},
		[3] = {},
		[4] = {alias_of = "gloss"},
		
		["dot"] = {},
		["gloss"] = {},
		["id"] = {},
		["tili"] = {required = tili == nil},
		["nodot"] = {type = "boolean"},
		["sc"] = {},
		["tr"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local tili = args["tili"] or "und"
	local sc = sc or args["sc"]
	
	tili = require("Module:tili").getByCode(tili) or error("The language code \"" .. tili .. "\" 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:form of").format_t((args[1] or "form") .. " of", args[2] or "term", args[3], tili, sc, args["id"], {gloss = args["gloss"], tr = args["tr"]})
end

function export.inflection_of_t(frame)
	local params = {
		[1] = {required = true},
		[2] = {},
		[3] = {list = true},
		
		["gloss"] = {},
		["id"] = {},
		["tili"] = {required = true},
		["nocap"] = {type = "boolean"},
		["nocat"] = {type = "boolean"},
		["nodot"] = {type = "boolean"},
		["sc"] = {},
		["tr"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local tili = args["tili"] or "und"
	local sc = args["sc"]
	
	tili = require("Module:tili").getByCode(tili) or error("The language code \"" .. tili .. "\" 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:form of").tagged_inflections(args[3], args[1] or "term", args[2], tili, sc, args["id"], {gloss = args["gloss"], tr = args["tr"]})
end

return export