Module:tln-conj

Revision as of 03:16, 20 June 2026 by Nehster9 (talk | contribs) (Created page with "local p = {} local endings = { are = { pres_1s = "§1S_ARE§", pres_2s = "§2S_ARE§", pres_3s = "§3S_ARE§", pres_1p = "§1P_ARE§", pres_2p = "§2P_ARE§", pres_3p = "§3P_ARE§" }, ere = { pres_1s = "§1S_ERE§", pres_2s = "§2S_ERE§", pres_3s = "§3S_ERE§", pres_1p = "§1P_ERE§", pres_2p = "§2P_ERE§", pres_3p = "§3P_ERE§" }, ire = { p...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


local p = {}

local endings = {
    are = {
        pres_1s = "§1S_ARE§",
        pres_2s = "§2S_ARE§",
        pres_3s = "§3S_ARE§",
        pres_1p = "§1P_ARE§",
        pres_2p = "§2P_ARE§",
        pres_3p = "§3P_ARE§"
    },

    ere = {
        pres_1s = "§1S_ERE§",
        pres_2s = "§2S_ERE§",
        pres_3s = "§3S_ERE§",
        pres_1p = "§1P_ERE§",
        pres_2p = "§2P_ERE§",
        pres_3p = "§3P_ERE§"
    },

    ire = {
        pres_1s = "§1S_IRE§",
        pres_2s = "§2S_IRE§",
        pres_3s = "§3S_IRE§",
        pres_1p = "§1P_IRE§",
        pres_2p = "§2P_IRE§",
        pres_3p = "§3P_IRE§"
    }
}

local function detect_class(title)
    if mw.ustring.match(title, "are$") then
        return "are"
    elseif mw.ustring.match(title, "ere$") then
        return "ere"
    elseif mw.ustring.match(title, "ire$") then
        return "ire"
    end

    return nil
end

local function make_link(form)
    return "[[" .. form .. "]]"
end

function p.show(frame)

    local args = frame:getParent().args

    local title = mw.title.getCurrentTitle().text

    local class = detect_class(title)

    if not class then
        return "Error: could not determine conjugation class."
    end

    local stem = mw.ustring.gsub(title, class .. "$", "")

    local forms = {}

    for slot, ending in pairs(endings[class]) do

        if args[slot] and args[slot] ~= "" then
            forms[slot] = args[slot]
        else
            forms[slot] = stem .. ending
        end

    end

    local text =
        '{| class="wikitable"\n' ..
        '|+ Present indicative\n' ..
        '|-\n' ..
        '! !! Singular !! Plural\n' ..
        '|-\n' ..
        '! First\n' ..
        '| ' .. make_link(forms.pres_1s) ..
        ' || ' .. make_link(forms.pres_1p) .. '\n' ..
        '|-\n' ..
        '! Second\n' ..
        '| ' .. make_link(forms.pres_2s) ..
        ' || ' .. make_link(forms.pres_2p) .. '\n' ..
        '|-\n' ..
        '! Third\n' ..
        '| ' .. make_link(forms.pres_3s) ..
        ' || ' .. make_link(forms.pres_3p) .. '\n' ..
        '|}'

    return text
end

return p