Jump to content

Module:io-conj

From Wiktionary, the free dictionary

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 p = {}

function p.init(frame)
    local intr = frame:getParent().args["intr"]
    local pagename = tostring( mw.title:getCurrentTitle() )
    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',
			palette = 'blue',
			tall = 'yes',
		}
	} .. [=[
!colspan=2 class="outer"|[[Image:Jankó-stelo.svg|50px|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 intr ~= "yes" 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 p