Module:io-conj

From Wiktionary, the free dictionary
Jump to navigation Jump to search

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)
    return p.conj(root, intr)
end

function p.conj(root, intr)
    local function link(affix)
        return require("Module:links").full_link({lang = lang, term = root .. affix})
    end
    local t = {"a", "i", "o"}
    local val = [=[<div class="NavFrame" style="max-width: 40em;">
<div class="NavHead">&nbsp; &nbsp; Conjugation of <span lang="io" style="font-style:italic;">]=] .. root .. [=[ar</span></div>
<div class="NavContent" style="overflow:auto">
{| style="background-color:#F9F9F9;border-collapse:separate;border-spacing:2px;width:100%" class="inflection-table"
|-
|style="background-color:#c8dfef;" colspan=2|[[Image:Jankó-stelo.svg|50px|link=|alt=]]
!style="background-color:#c8dfef;" colspan=2|present
!style="background-color:#c8dfef;" colspan=2|past
!style="background-color:#c8dfef;" colspan=2|future]=]
    local function threecells(preword, affix, words)
        val = val .. "\n|-\n!style=\"background-color:#c8dfef;\" colspan=2|" .. preword

        for i = 1, 3, 1 do
            val = val .. "\n|style=\"background-color:#F9F9F9;\" colspan=2|"

            if type(affix) == "table" then
                if affix[i] ~= "" then
                    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!style=\"background-color:#c8dfef;\" rowspan=2|" .. preword

        val = val .. "\n!style=\"background-color:#c8dfef;\"|singular"
        for i = 1, 3, 1 do
            val = val .. "\n|style=\"background-color:#F9F9F9;\" colspan=2|" .. link(t[i] .. interfix .. "o")
        end

        val = val .. "\n|-\n!style=\"background-color:#c8dfef;\"|plural"
        for i = 1, 3, 1 do
            val = val .. "\n|style=\"background-color:#F9F9F9;\" 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 active participle", "nt")
    if intr ~= "yes" then threecells("adjective passive participle", "ta") end
    if intr ~= "yes" then threecells("adverbial passive participle", "te") end
    if intr ~= "yes" then sixcells("nominal passive participle", "t") end

val = val .. [=[

|}
</div></div>]=]

    return val
end

return p