Jump to content

Module:io-conj

From Wiktionary, the free dictionary

Notice This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

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

local export = {}

function export.init(frame)
	local args = require("Module:parameters").process(frame:getParent().args, {
		intr = {type = "boolean"},
		pagename = true,
	})
    local pagename = args.pagename or mw.loadData("Module:headword/data").pagename
    local root = string.sub(pagename, 0, -3)
    local function link(affix)
        return require("Module:links").full_link({lang = lang, term = root .. affix})
    end
    local t = {"a", "i", "o"}
    local val = frame:expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = 'Conjugation of <span lang="io" style="font-style:italic;">' .. root .. 'ar' .. '</span>',
			palette = 'blue',
			tall = 'yes',
		}
	} .. [=[
!colspan=2 class="outer"|[[File:Jankó-stelo.svg|30px|link=|alt=]]
!colspan=2|present
!colspan=2|past
!colspan=2|future]=]
    local function threecells(preword, affix, words)
        val = val .. "\n|-\n!colspan=2|" .. preword

        for i = 1, 3, 1 do
            val = val .. "\n|colspan=2|"

            if type(affix) == "table" then
                if affix[i] == "" then
                	val = val .. "&mdash;"
                else
                    val = val .. link(affix[i])
                end
            else
                val = val .. link(t[i] .. affix)
            end
        end
    end

    local function sixcells(preword, interfix)
        val = val .. "\n|-\n!rowspan=2|" .. preword

        val = val .. "\n!class=secondary|singular"
        for i = 1, 3, 1 do
            val = val .. "\n|colspan=2|" .. link(t[i] .. interfix .. "o")
        end

        val = val .. "\n|-\n!class=secondary|plural"
        for i = 1, 3, 1 do
            val = val .. "\n|colspan=2|" .. link(t[i] .. interfix .. "i")
        end
    end

    threecells("infinitive", "r")
    threecells("tense", "s")
    threecells("conditional", {"us", "", ""})
    threecells("imperative", {"ez", "", ""})
    threecells("adjective active participle", "nta")
    threecells("adverbial active participle", "nte")
    sixcells("nominal<br>active participle", "nt")
    if not args.intr then
    	threecells("adjective passive participle", "ta")
    	threecells("adverbial passive participle", "te")
    	sixcells("nominal<br>passive participle", "t")
    end

    val = val .. '\n' .. frame:expandTemplate{ title = 'inflection-table-bottom' }

    return val
end

return export