Module:fr-conj/sandbox

local export = {} local m_links = require("Module:links")

local lang = require("Module:languages").getByCode("fr")

-- defined below local format_links, categorize

--entry point function export.frconj(frame) --are we directly embedding through Template:fr-conj or calling the module? local args = {} if frame.args["direct"] == "yes" then args = frame:getParent.args else args = frame.args end --create the forms local data = {forms = {}, categories = {}, en = false, y = false, yen = false, l = false, le = false, la = false, les = false, l_en = false, l_y = false, l_yen = false, lesen = false, lesy = false, lesyen = false, refl = false, reflen = false, refll = false, reflle = false, reflla = false, reflles = false, reflly = false, refllesy = false, refly = false, reflyen = false, aux = ""} data.aux = args["aux"] if not (data.aux == "avoir" or data.aux == "être") then data.aux = "avoir or être" end if (args["inf"] == nil or args["inf"] == "" or args["inf"] == mw.title.getCurrentTitle.text) then data.forms.inf_nolink = mw.title.getCurrentTitle.text else data.forms.inf_nolink = format_links(args["inf"]) end data.forms.pp = format_links(args["pp"]) data.forms.ppr = format_links(args["ppr"]) if (args["pp"] == "—") then data.forms.pp_nolink = "—" elseif (args["pp"] == nil or mw.title.getCurrentTitle.text) then data.forms.pp_nolink = mw.title.getCurrentTitle.text else data.forms.pp_nolink = format_links(args["pp"]) end if (args["ppr"] == "—") then data.forms.ppr_nolink = "—" elseif (args["ppr"] == nil or mw.title.getCurrentTitle.text) then data.forms.ppr_nolink = mw.title.getCurrentTitle.text else data.forms.ppr_nolink = format_links(args["ppr"]) end local form_params = { "ind.p.1s", "ind.p.2s", "ind.p.3s", "ind.p.1p", "ind.p.2p", "ind.p.3p", "ind.i.1s", "ind.i.2s", "ind.i.3s", "ind.i.1p", "ind.i.2p", "ind.i.3p", "ind.ps.1s", "ind.ps.2s", "ind.ps.3s", "ind.ps.1p", "ind.ps.2p", "ind.ps.3p", "ind.f.1s", "ind.f.2s", "ind.f.3s", "ind.f.1p", "ind.f.2p", "ind.f.3p", "cond.p.1s", "cond.p.2s", "cond.p.3s", "cond.p.1p", "cond.p.2p", "cond.p.3p", "sub.p.1s", "sub.p.2s", "sub.p.3s", "sub.p.1p", "sub.p.2p", "sub.p.3p", "sub.pa.1s", "sub.pa.2s", "sub.pa.3s", "sub.pa.1p", "sub.pa.2p", "sub.pa.3p", "imp.p.2s", "imp.p.1p", "imp.p.2p", }	for _, form in ipairs(form_params) do		local key = form:gsub("%.", "_") data.forms[key] = format_links(args[form]) local alt = form .. ".alt" local alt_arg = args[alt] if not (alt_arg == nil or alt_arg == "" or alt_arg == "—") then data.forms[key] = data.forms[key] .. " or " .. format_links(alt_arg) end end --a few ugly hacks data.forms.ger = args["ger.override"] data.forms.inf_comp = args["inf.override"] data.forms.ger_comp = args["ger.comp.override"] --finish up	if mw.title.getCurrentTitle.nsText == "" then return export.make_table(data) .. categorize(args,data) else return export.make_table(data) end end function format_links(link) if (link == nil or link == "" or link == "—") then return "—" else return m_links.full_link({lang = lang, term = link}) end end

function categorize(args, data) output = "" if args.group == "1" or args.group == "1st" or args.group == "first" then output = output .. ""	elseif args.group == "2" or args.group == "2st" or args.group == "second" then output = output .. ""	elseif args.group == "3" or args.group == "3rd" or args.group == "third" then output = output .. ""	end if data.aux == "être" then output = output .. ""	elseif data.aux == "avoir or être" then output = output .. ""	end return output end

--split from Module:fr-verb/core function export.make_table(data) local colors = { top = "#F0F0F0", gray = "#C0C0C0", straw = "#e2e4c0", blue = "#c0cfe4", gray_text = "#7f7f7f", green = "#c0e4c0", tan = "#e4d4c0", }	local aux_gerund = "" if data.aux == "avoir" then aux_gerund = "ayant" elseif data.aux == "s'être" then aux_gerund = "s'étant" elseif data.aux == "s'en être" then aux_gerund = "s'en étant" elseif data.aux == "s'y être" then aux_gerund = "s'y étant" elseif data.aux == "s'y en être" then aux_gerund = "s'y en étant" elseif data.aux == "se l'être" then aux_gerund = "se l'étant" elseif data.aux == "se les être" then aux_gerund = "se les étant" elseif data.aux == "l'en avoir" then aux_gerund = "l'en ayant" elseif data.aux == "l'y en avoir" then aux_gerund = "l'y en ayant" elseif data.aux == "les en avoir" then aux_gerund = "les en ayant" elseif data.aux == "les y en avoir" then aux_gerund = "les y en ayant" elseif data.aux == "se les y être" then aux_gerund = "se les y étant" elseif data.aux == "se l'y être" then aux_gerund = "se l'y étant" elseif data.aux == "l'avoir" then aux_gerund = "l'ayant" elseif data.aux == "l'être" then aux_gerund = "l'étant" elseif data.aux == "l'avoir or être" then aux_gerund = "l'ayant or étant" elseif data.aux == "l'y avoir" then aux_gerund = "l'y ayant" elseif data.aux == "l'y être" then aux_gerund = "l'y étant" elseif data.aux == "l'y avoir or être" then aux_gerund = "l'y ayant or étant" elseif data.aux == "les avoir" then aux_gerund = "les ayant" elseif data.aux == "les être" then aux_gerund = "les étant" elseif data.aux == "les avoir or être" then aux_gerund = "les ayant or étant" elseif data.aux == "les y avoir" then aux_gerund = "les y ayant" elseif data.aux == "les y être" then aux_gerund = "les y étant" elseif data.aux == "les y avoir or être" then aux_gerund = "les y ayant or étant" elseif data.aux == "y avoir" then aux_gerund = "y ayant" elseif data.aux == "y être" then aux_gerund = "y étant" elseif data.aux == "y avoir or être" then aux_gerund = "y ayant or étant" elseif data.aux == "y en avoir" then aux_gerund = "y en ayant" elseif data.aux == "y en être" then aux_gerund = "y en étant" elseif data.aux == "y en avoir or être" then aux_gerund = "y en ayant or étant" elseif data.aux == "en avoir" then aux_gerund = "en ayant" elseif data.aux == "en être" then aux_gerund = "en étant" elseif data.aux == "en avoir or être" then aux_gerund = "en] [[ayant or étant"	elseif data.aux == "être" then		aux_gerund = "étant"	else		aux_gerund = "ayant or étant"	end	local result = {}	local inv = data.forms.pp_nolink	local inv_sub = data.forms.pp_nolink	local inversion_note = ""	local inversion_sub_note = ""	local replacement_note = "2"	--Until someone implements a better solution	if inv == "estimé" or inv == "opiné" or inv == "parlé" or inv == "pensé" or inv == "opiné" or inv == "trouvé" or (inv == "pu" and data.refl == false) then		inversion_note = "2"		inversion_sub_note = "2"		replacement_note = "3"		if inv == "pu" then			inv = "puis"			inv_sub = "puissé"			inversion_sub_note = "3"			replacement_note = "4"		end	end	-- Template parameter syntax refers to the corresponding item in the	-- data.forms or colors table:	-- -> data.forms.inf_nolink	-- 		-> colors.green	if data.notes then table.insert(result, data.notes .. '\n') end	table.insert(result, [=[ Conjugation of  (see also Appendix:French verbs)  ]=])	--	setmetatable(data.forms, { __index =		function(t, k)			mw.log('No key for ' .. k)		end	})	--	return string.gsub(table.concat(result), "}",		function(code)			return data.forms[code] or colors[code]		end) end

return export