Difference between revisions 40119 and 40120 on test2wiki

-- This is a test of scribbling. Using Italian templates from en.wiktionary.
-- Owner SemperBlotto
local p = {}

function p.itadj(frame)
    local pframe = frame:getParent()
    local args = pframe.args
    local stem = args[1] or error("1st parameter (stem of adjective) missing!")
(contracted; show full)        else cat = "[[category:Italian nouns]]"
    end
    return headword .. cat
end

function p.wiki(x)
-- For use within p.itconj function.
-- Wikifies term
, converting nils to single spaces (for ease of concatenation).
    if x == nil then return " " end
    return "[[" .. x .. "]]"
end

function p.alts(x,y)
-- For use within p.itconj function.
-- Adds alternate forms with a comma in between.
    if y ~= " " then return x .. ", " .. y end
    return x
end

function p.itconj(frame)
-- This function builds pretty tables for Italian verb conjugation.
-- It is called by other templates/functions for regular verbs, and called directly for some irregular ones.
    local pframe = frame:getParent()
    local args = pframe.args
    local inf = args["inf"] or error("Infinitive missing!")
    local aux = args["aux"] or "avere"
-- Get all the inflected forms and their alternative forms (at least 1 alt each)
    local ger = p.wiki(args["ger"])
    local ger2 = p.wiki(args["ger2"])
    ger = p.alts(ger, ger2)
    local presp = p.wiki(args["presp"])
    local presp2 = p.wiki(args["presp2"])
    presp = p.alts(presp, presp2)
    local pastp = p.wiki(args["pastp"])
    local pastp2 = p.wiki(args["pastp2"]); local pastp3 = p.wiki(args["pastp3"]); local pastp3 = p.wiki(args["pastp3"]); local pastp4 = p.wiki(args["pastp4"])
    pastp = p.alts(pastp, pastp2)
    pastp = p.alts(pastp, pastp3)
    pastp = p.alts(pastp, pastp4)
--    local pres1ps = p.wiki(args["pres1ps"] or ""); local pres2s = p.wiki(args["pres2s"]); local pres2p3s = p.wiki(args["pres2p"] or ""3s"])
    local pres1p = p.wiki(args["pres1p"]); local pres32p = p.wiki(args["pres32p"] or ""
--); local pres3p = p.wiki(args["pres3p"])
    local pres1s2 = p.wiki(args["pres1s2"]); local pres2s2 = p.wiki(args["pres2s2"]); local pres2s2 = p.wiki(args["pres2s2"])
--    local pres1p2 = p.wiki(args["pres1p2"]); local pres2p2 = p.wiki(args["pres2p2"]); local pres3p2 = p.wiki(args["pres3p2"]    
--)
    pres1s = p.alts(pres1s, pres1s2); pres2s = p.alts(pres2s, pres2s2); pres3s = p.alts(pres3s, pres3s2) 
--    pres1p = p.alts(pres1p, pres1p2); pres2p = p.alts(pres2p, pres2p2); pres3p = p.alts(pres3p, pres3p2)     
--    local imperf1s = args["imperf1s"] or ""; local imperf2s = args["imperf2s"] or ""; local imperf3s = args["imperf3s"] or ""
--    local imperf1p = args["imperf1p"] or ""; local imperf2p = args["imperf2p"] or ""; local imperf3p = args["imperf3p"] or ""
(contracted; show full)
    conj = conj .. '! style="background:#c0cfe4" | lui/lei\n'
    conj = conj .. '! style="background:#c0cfe4" | noi\n'
    conj = conj .. '! style="background:#c0cfe4" | voi\n'
    conj = conj .. '! style="background:#c0cfe4" | essi/esse\n|-\n'
    conj = conj .. '! style="height:3em;background:#c0cfe4" colspan="1" | present\n'

--    conj = conj .. '|' .. mi .. pres1s .. '\n|' .. ti .. pres2s .. '\n|' .. si .. pres3s .. '\n|' .. ci .. pres1p .. '\n|' .. vi .. pres2p .. '\n|' .. si .. pres3p .. '\n'
    conj = conj .. '|-\n! style="height:3em;background:#c0cfe4" colspan="1" | imperfect\n'
--    conj = conj .. '|' .. mi .. imperf1s .. '\n|' .. ti .. imperf2s .. '\n|' .. si .. imperf3s .. '\n|' .. ci .. imperf1p .. '\n|' .. vi .. imperf2p .. '\n|' .. si .. imperf3p .. '\n'    
    
    conj = conj .. '|-\n'    
    
    conj = conj .. '|}</div></div>'
    return conj
    
end

return p