Module:User:Benwing2/indtr

local m_lb = require("Module:labels") local export = {}

function export.show(frame) local args = frame:getParent.args local pagename = mw.title.getCurrentTitle.text

if (args[1] == nil and mw.title.getCurrentTitle.nsText == "Template") then args[1] = "und" end local lang = require("Module:languages").getByCode(args[1], 1) local nocat = args["nocat"] ~= nil local sort_key = args["sort"] local term_mode = (frame.args["term"]) ~= nil local labels = get_labels(args, require("Module:languages").getByCode(args[1]):getCanonicalName) return m_lb.show_labels { labels = labels, lang = lang, sort = sort_key, nocat = nocat, mode = "term-label", } end

function get_labels(args, langname) local labels = {} local indtr = "" local i = 2 local q = nil local first = true local andwith = false if (args["intr"] ~= nil) then indtr = indtr .. "intransitive, or " end while (args[i] ~= nil) do		if (mw.ustring.sub(args[i], 0, 1) == ".") then table.insert(labels, mw.ustring.sub(args[i], 2)); elseif (args[i] == ";") then andwith = true if (args[("qual" .. (i-1))] == nil or args[("qual" .. (i-1))] == "") then indtr = indtr .. " and with " else indtr = indtr .. " and " .. args[("qual" .. (i-1))] .. " with " end else if (first == false) then if (andwith == true) then andwith = false else indtr = indtr .. " or " end else if (args["cop"] ~= nil and args["ditr"] ~= nil) then indtr = indtr .. "ditransitive, copulative with " elseif (args["cop"] ~= nil) then indtr = indtr .. "copulative}} with "				elseif (args["ditr"] ~= nil) then					indtr = indtr .. "[[Appendix:Glossary#ditransitive|ditransitive, with the indirect object taking "				elseif (args["aux"] ~= nil) then					indtr = indtr .. "auxiliary with "				else					indtr = indtr .. "transitive with "				end				first = false			end			if (mw.ustring.sub(args[i], 0, 1) == "-") then				indtr = indtr .. mw.ustring.sub(args[i], 2);			else				indtr = indtr .. "" .. args[i] .. ""			end			indtr = indtr .. qualifier(args[("qual" .. (i-1))])		end		i = i + 1	end	if (args["direct"] ~= nil) then 		if (args["ditr"] ~= nil) then			indtr = indtr .. " or no preposition"		else			indtr = indtr .. " or with no preposition"		end		indtr = indtr .. qualifier(args["qualdirect"])	end	if (args["aux"] ~= nil) then		indtr = indtr .. " and a verb in the " .. args["aux"]	elseif (args["cop"] ~= nil and args["ditr"] ~= nil) then		indtr = indtr .. " for the second object"	end	table.insert(labels, indtr)	return labels

end

function qualifier(text) if (text == nil or text == "") then return "" end return ' (   ' .. text .. '   )  ' end

return export