Modulo:forma flesionada
Inpostasion de letura
La documentazione per questo modulo può essere creata in Modulo:forma flesionada/man
--riadatà da ca:Mòdul:forma_flexionada--
local export = {}
local m_links = require("Module:lighi")
local inflection_tags = {
-- Gènere
["m"] = "mascułin",
["f"] = "femenin",
["n"] = "nèutro",
["c"] = "comun",
-- Nombre
["s"] = "singołar",
["p"] = "plurałe",
["d"] = "duałe",
-- Gènere i nombre
["ms"] = "mascułin singołar",
["mp"] = "mascułin plurałe",
["fs"] = "femenin singołar",
["fp"] = "femenin plurałe",
["ns"] = "nèutro singołar",
["np"] = "nèutro plurałe",
-- Estat
["def"] = "definio",
["indef"] = "indefinio",
-- Declinació
["abl"] = "ablativo",
["abs"] = "asołutivo",
["aso"] = "asołutivo",
["ac"] = "acuzativo",
["al"] = "ałativo",
["aldir"] = "ałativo diresionałe",
["ben"] = "benfativo",
["caus"] = "cauzałe",
["com"] = "comitativo",
["dat"] = "dativo",
["erg"] = "ergativo",
["gen"] = "zenitivo",
["genloc"] = "zenitivo locativo",
["zen"] = "zenitivo",
["zenloc"] = "zenitivo locativo",
["ines"] = "inesivo",
["str"] = "strumentałe",
["loc"] = "locativo",
["nom"] = "nominativo",
["part"] = "partitivo",
["prol"] = "prołativo",
["term"] = "terminativo",
["voc"] = "vocativo",
-- Conjugació
-- Persona
["1"] = "prima persona singołar",
["2"] = "segonda persona singołar",
["3"] = "tersa persona singołar",
["4"] = "prima persona plurałe",
["5"] = "segonda persona plurałe",
["6"] = "tersa persona plurałe",
-- Temps
["pres"] = "del prezente",
["imperf"] = "de l'inperfeto",
["perf"] = "del perfeto",
["pret"] = "del pretèrito",
["pass"] = "del pasà",
["fut"] = "del futuro",
["cond"] = "del condisionałe",
-- Mode
["imp"] = "de l'imperativo",
["ind"] = "d'indicativo",
["subj"] = "de suzontivo",
-- Veu
["act"] = "ativo",
["pas"] = "pasivo",
-- Impersonals
["inf"] = "infinitivo",
["part"] = "partisìpio",
["ger"] = "zerùndio"
}
local pronoms = {}
pronoms["ca"] = {"jo", "tu", "[[ell]], [[ella]], [[vostè]]",
"nosaltres", "[[vosaltres]], [[vós]]", "[[ells]], [[elles]], [[vostès]]"}
pronoms["de"] = {"ich", "du", "[[er]], [[sie]], [[es]]",
"wir", "ihr", "sie"}
pronoms["fr"] = {"[[je]]/[[j']]", "tu", "[[il]], [[elle]], [[on]]",
"nous", "vous", "[[ils]], [[elles]]"}
pronoms["it"] = {"io", "tu", "[[lui]]/[[lei]], [[esso]]/[[essa]]",
"noi", "voi", "[[loro]], [[essi]]/[[esse]]"}
pronoms["oc"] = {"[[ieu]], [[jo]]", "tu", "[[el]]/[[eth]], [[ela]]/[[era]]",
"[[nosautres]]/[[nosati]], [[nosautras]]/[[nosates]]", "[[vosautres]]/[[vosati]], [[vosautras]]/[[vosates]]", "[[eles]]/[[eri]], [[elas]]/[[eres]]"}
pronoms["pt"] = {"eu", "tu", "[[ele]], [[ela]], [[você]]",
"nós", "vós", "[[eles]], [[elas]], [[vocês]]"}
pronoms["vec"] = {"mi", "ti", "[[eło]]/[[eła]], [[lù]]",
"[[noaltri]]/[[nu]]", "[[voaltri]]/[[vu]]", "[[lori]]/[[lore]],"}
local function get_terminfo(frame)
local args = frame:getParent().args
local iargs = frame.args
local term = iargs["term"] or args[2]; if term == "" then term = nil end
local alt = args["alt"]; if alt == "" then alt = nil end
local lang = iargs["lang"] or args[1]; if lang == "" then lang = "vec" end
local sc = iargs["sc"] or args["sc"]; if sc == "" then sc = nil end
local id = iargs["id"] or args["id"]; if id == "" then id = nil end
local gloss = args["glossa"]; if gloss == "" then gloss = nil end
local tr = args["tr"]; if tr == "" then tr = nil end
if not lang then
lang = "vec"
elseif not require("Module:łéngua").existeix(lang) then
error("Codaze de lengua incoreto")
end
return {term = term, alt = alt, langcode = lang, sc = sc, id = id, gloss = gloss, tr = tr}
end
local function get_categories(frame, lang)
local args = frame:getParent().args
local iargs = frame.args
local cat = iargs["cat"] or args["cat"]; if cat == "" then cat = nil end
local cat2 = iargs["cat2"] or args["cat2"]; if cat2 == "" then cat2 = nil end
local categories = {}
if cat then table.insert(categories, cat) end
if cat2 then table.insert(categories, cat2) end
local ret = ""
if #categories > 0 then
ret = require("Mòdul:utilitats").format_categories(categories, lang, nil)
end
return ret
end
function format_t(text, terminfo, categories)
if not terminfo.term then
if mw.title.getCurrentTitle().nsText == "Modèl" then
terminfo.term = "tèrmano"
else
error("No hi ha cap terme per enllaçar-hi.")
end
end
if not text then
error("No s'ha proporcionat cap definició.")
end
return
"<i>" .. text .. "</i> "
.. m_links.full_link(terminfo, "negreta", nil)
.. categories
end
function export.form_of_t(frame)
local text = frame.args[1]; if text == "" then text = nil end
local terminfo = get_terminfo(frame)
local categories = get_categories(frame, terminfo.langcode)
return format_t(text, terminfo, categories)
end
function export.inflection_t(frame)
local args = frame:getParent().args
local terminfo = get_terminfo(frame)
local categories = get_categories(frame, terminfo.langcode)
local inflections = {}
local i = 3
local infl = args[i] or 'forma declinada'
while infl do
if infl ~= "" then
table.insert(inflections, inflection_tags[infl] or infl)
local person = tonumber(infl)
-- tonumber("inf") returns number infinite instead of expected nil
if person and person < 7 and pronoms[terminfo.langcode] then
table.insert(inflections, "(" .. m_links.language_link({term = pronoms[terminfo.langcode][person], langcode = terminfo.langcode}) .. ")")
end
end
i = i + 1
infl = args[i]
end
local ret = table.concat(inflections, " ")
ret = string.gsub(ret, " , ", ", ")
return format_t(ret .. " de", terminfo, categories)
end
function export.form_eo_t(frame)
local terminfo = get_terminfo(frame)
local categories = get_categories(frame, terminfo.langcode)
local args = frame:getParent().args
local text = args[2]; if text == "" then text = nil end
terminfo.term = args[1] or mw.title.getCurrentTitle().subpageText
if not text then
if terminfo.term:find("j$") then
text = 'forma plurałe'
terminfo.term = terminfo.term:gsub("j$", "")
elseif terminfo.term:find("jn$") then
text = 'acusatiu plurałe'
terminfo.term = terminfo.term:gsub("jn$", "")
elseif terminfo.term:find("n$") then
text = 'acusatiu'
terminfo.term = terminfo.term:gsub("n$", "")
elseif terminfo.term:find("as$") then
text = 'present'
terminfo.term = terminfo.term:gsub("as$", "i")
elseif terminfo.term:find("is$") then
text = 'passat'
terminfo.term = terminfo.term:gsub("is$", "i")
elseif terminfo.term:find("os$") then
text = 'futur'
terminfo.term = terminfo.term:gsub("os$", "i")
elseif terminfo.term:find("us$") then
text = 'condicional'
terminfo.term = terminfo.term:gsub("us$", "i")
elseif terminfo.term:find("u$") then
text = 'imperatiu'
terminfo.term = terminfo.term:gsub("u$", "i")
else
text = 'forma desconosesta'
end
end
return format_t(text .. " de", terminfo, categories)
end
return export