Module:cop-conj-table

--[=[ Translation of https://en.wiktionary.org/w/index.php?oldid=68887543 ]=]

local export = {}

local lang = require("Module:languages").getByCode("cop") local m_links = require("Module:links") local m_string_utilities = require("Module:string utilities") local m_param = require("Module:parameters") local m_cop_translit = require("Module:Copt-translit")

local current_title = mw.title.getCurrentTitle local NAMESPACE = current_title.nsText local PAGENAME = current_title.text

-- replaces [t] local function wrapper(t) return ' ' .. t .. ' ' end

--replaces Module:table tools.linkify_entry local function linkify_entry(t) t = mw.text.split(t or '', ', ', true) for i, form in ipairs(t) do		t[i] = m_links.language_link{lang = lang, term = form} end return table.concat(t, ', ') end

--replaces Module:table tools.translit_entry local function translit_entry(t) return m_cop_translit.tr((t or ):gsub('[%[%]]+',)) end

-- replaces T:cop-table entry local function table_entry(t) return ' ' .. wrapper(linkify_entry(t)) .. ' '		.. translit_entry(t) .. ' ' end

function export.show(frame) local params = { ["head"] = {}, ["dialect-wiki-page"] = {}, ["dialect"] = {}, ["inf"] = {}, ["imp"] = {}, ["inf-neg"] = {}, ["imp-neg"] = {}, ["circ-II-syncretism"] = {}, ["fut"] = {}, ["dur-neg"] = {}, ["circ"] = {}, ["pst-rel"] = {}, ["pst-rel2"] = {}, ["rel"] = {}, ["pst-pret"] = {}, ["pret"] = {}, ["prec-pst-II-syncretism"] = {}, ["pst-II"] = {}, ["aor-rel"] = {}, ["II"] = {}, ["clause-neg"] = {}, ["notes"] = {}, }	local prefixes = { [1] = "prs", [2] = "prs-circ", [3] = "prs-rel", [4] = "prs-pret", [5] = "prs-II", [6] = "fut", [7] = "fut-circ", [8] = "fut-rel", [9] = "fut-pret", [10] = "fut-II", [11] = "pst", [12] = "pst-neg", [13] = "pst-circ", [14] = "pst-circ-neg", [15] = "pst-rel", [16] = "pst-rel-neg", [17] = "pst-pret", [18] = "pst-pret-neg", [19] = "pst-II", [20] = "expv", [21] = "expv-circ", [22] = "expv-rel", [23] = "expv-pret", [24] = "aor", [25] = "aor-neg", [26] = "aor-circ", [27] = "aor-circ-neg", [28] = "aor-rel", [29] = "aor-rel-neg", [30] = "aor-pret", [31] = "aor-pret-neg", [32] = "aor-II", [33] = "opt", [34] = "opt-neg", [35] = "jus", [36] = "jus-neg", [37] = "cnjv", [38] = "cnjv-fut", [39] = "prec", [40] = "lim", [41] = "cond", [42] = "cond-short", }	local persons = { [1] = "1-sg", [2] = "2-sg-m", [3] = "2-sg-f", [4] = "3-sg-m", [5] = "3-sg-f", [6] = "1-pl", [7] = "2-pl", [8] = "3-pl", [9] = "nom", [10] = "nom_", }	local function name(i,j) return (prefixes[i] or i)..'-'..persons[j] end for i=1,42 do		for j=1,9 do			params[name(i,j)] = {} end end for j=1,8 do		params[persons[j]] = {} end local args = m_param.process(frame:getParent.args, params) local function get(i,j) return args[name(i,j)] end args.term = '' .. args.head .. '' args.dialect_wiki = '' .. args.dialect .. ' dialect' args.inf = table_entry(args.inf or args.head) args.imp = table_entry(args.imp or args.head) args['inf-neg'] = table_entry(args['inf-neg'] .. args.head) args['imp-neg'] = table_entry(args['imp-neg'] .. args.head) -- i=1 args['prs-nom_'] = args.head -- i=6,10 for i=6,10 do		for j=1,8 do args[name(i,j)] = get(i,j) or ((get(i-5,j) or '') .. args.fut) end end args[name(6,10)] = args.fut .. args.head for i=7,10 do args[name(i,10)] =  .. (get(i,9) or get(i-5,9) or ) .. ' ' .. args.fut .. args.head .. '' end for j=1,9 do -- i=13,19 for i=13,14 do args[name(i,j)] = get(i,j) or (args.circ .. get(i-2,j)) end args[name('pst-rel',j)] = get(15,j) or {args['pst-rel'] .. get('pst',j), args['pst-rel2'] and (args['pst-rel2'] .. get('pst',j))} args[name('pst-rel-neg',j)] = get(16,j) or (args.rel .. get(12,j)) for i=17,18 do args[name(i,j)] = get(i,j) or ((args['pst-pret'] or args.pret) .. get(i-6,j)) end args[name('pst-II',j)] = get(19,j) or (args['pst-II'] .. get(11,j)) -- i=21,23 args[name('expv-circ',j)] = get(21,j) or (args.circ .. get('expv',j)) args[name('expv-rel',j)] = get(22,j) or (args.rel .. get('expv',j)) args[name('expv-pret',j)] = get(23,j) or (args.pret .. get('expv',j)) -- i=26,32 args[name('aor-circ',j)] = get(26,j) or (args.circ .. get('aor',j)) args[name('aor-circ-neg',j)] = get(27,j) or (args.circ .. get('aor-neg',j)) args[name('aor-rel',j)] = get(28,j) or {args.rel .. get('aor',j), args['aor-rel'] and (args['aor-rel'] .. get('aor',j))} args[name('aor-rel-neg',j)] = get(29,j) or (args.rel .. get('aor-neg',j)) args[name('aor-pret',j)] = get(30,j) or (args.pret .. get('aor',j)) args[name('aor-pret-neg',j)] = get(31,j) or (args.pret .. get('aor-neg',j)) args[name('aor-II',j)] = get(32,j) or (args.II .. get('aor-neg',j)) end for _, range in ipairs({{2,5},{11,42}}) do		for i=range[1],range[2] do mw.log(i) local forms = get(i,9) if type(forms) == 'string' then args[name(i,10)] =  .. forms .. ' ' .. args.head ..  elseif forms then for k,form in ipairs(forms) do forms[k] =  .. form .. ' ' .. args.head ..  end args[name(i,10)] = table.concat(forms, ', ') end end end for i=1,42 do		for j=1,8 do			local form = get(i,j) if form then if type(form) == 'string' then args[name(i,j)] = table_entry(form .. args.head) else for k,subform in ipairs(form) do form[k] = subform .. args.head end args[name(i,j)] = table_entry(table.concat(form, ', ')) end end end args[name(i,10)] = table_entry(get(i,10)) end args.rowspan = args['circ-II-syncretism'] and '4' or '5' args['dur-neg'] = table_entry(args['dur-neg']) args['clause-neg'] = table_entry(args['clause-neg']) args['notes'] = args['notes'] or '' local table_text = [=[ Conjugation of {term} ({dialect_wiki}) return m_string_utilities.format(table_text, args) end

return export