Module:User:Jberkel/pt-conj/table

local exports = {} local lang = require('Module:languages').getByCode('pt')

local function makeLink(term, face, allow_self_link) local m_links = require('Module:links') return m_links.full_link({term = term, lang = lang}, face, allow_self_link) end

local function verbInformation(verb_data) local function verbDescription local description = "This is " if verb_data.irregular then description = description .. "an irregular " else description = description .. "a regular " end if verb_data.abundant then description = description .. "abundant " end if verb_data.defective then description = description .. "defective " end return description .. "verb of the '''-" .. verb_data.suffix .. "''' group." end

local function verbExamples local examples = {} for i, verb in ipairs(verb_data.examples) do           table.insert(examples,  makeLink(verb, 'term', true)) end return table.concat(examples, ', ') end

local module = string.sub(verb_data.suffix, #verb_data.suffix-1) local edit_link = "[".. tostring(mw.uri.fullUrl( "Module:pt-conj/data/-"..module, {action='edit'})) .." [edit]]"

return "Notes:" .. edit_link .. " \n" .. "* " .. verbDescription .. "\n" .. "* " .. table.concat(verb_data.comments, "\n* ") .. "\n" .. "* Verbs with this conjugation include: " .. verbExamples .. "." end

local function navHeadText(verb_data) return " Conjugation of the " ..            lang:getCanonicalName .. " -" ..            verb_data.suffix .. " verb " .. "''" .. verb_data.forms.infn.impe .. "''" end

-- main entry point for this module, renders table with all verb forms function exports.create(verb_data) local has_short_pp = verb_data.forms.short_part_past and verb_data.forms.long_part_past local function lookup(s) local parts = mw.text.split(s, '%.') local f = verb_data.forms for i, k in ipairs(parts) do           if f == nil then break end f = f[k] end return f   end

local function linkForm(form) return makeLink(form, nil, false) end

local function verbForm(param) local stdform = lookup(param) local text = stdform and stdform ~= '' and linkForm(stdform) or '-' local altforms = lookup(param .. '_alt') local defective = lookup(param .. '_defective') local obsolete = lookup(param .. '_obsolete') if altforms then for _, form in ipairs(altforms) do               text = text .. ' ' ..linkForm(form) end end if defective then text = text .. " Normally defective: ''" .. linkForm(defective) .. "''"       end if obsolete then text = text .. " Obsolete: ''" .. linkForm(obsolete) .. "''"       end return text end

local function repl(param) if param == 'navhead' then return navHeadText(verb_data) elseif param == 'verbInformation' then return verbInformation(verb_data) elseif param then return verbForm(param) end end

local function pastParticiple if has_short_pp then return [=[ ! style="border: 1px solid #999999; background:#ffc498" colspan="7" | Short past participle[1] ! style="border: 1px solid #999999; background:#dfa478" | Masculine ! style="border: 1px solid #999999; background:#dfa478" | Feminine ! style="border: 1px solid #999999; background:#ffc498" colspan="7" | Long past participle[2] ! style="border: 1px solid #999999; background:#dfa478" | Masculine ! style="border: 1px solid #999999; background:#dfa478" | Feminine ]=]       else return [=[ ! style="border: 1px solid #999999; background:#ffc498" colspan="7" | Past participle ! style="border: 1px solid #999999; background:#dfa478" | Masculine ! style="border: 1px solid #999999; background:#dfa478" | Feminine ]=]       end end
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |
 * style="border: 1px solid #999999; vertical-align: top;" colspan="3" |

local wikicode = [=[ ]=] .. (has_short_pp and [=[ ]=] or '') .. [=[           ]=]    local replaced, _ = mw.ustring.gsub(wikicode, "", repl) return replaced end
 * [1] Used with auxiliary verbs ser and estar;
 * [2] Used with auxiliary verbs haver and ter.

return exports