Módulo:t
Apariencia
La documentación para este módulo puede ser creada en Módulo:t/doc
local export = {}
local insert = table.insert
local concat = table.concat
local m_str = require("Módulo:String")
local ucfirst = m_str.ucfirst
local substr = m_str.sub
local strfind = m_str.find
local strsplit = m_str.split
local generar_error = require("Módulo:traza")
local obtener_idioma = require("Módulo:lenguas").cod_a_idioma
local obtener_familia = require("Módulo:lenguas").cod_a_familia
local booleano = require("Módulo:sí-no")
local function mostrar_(frame, categorizar)
local title = mw.title.getCurrentTitle().fullText
if title == "Plantilla:t" or title == "Plantilla:d" then
return "Use esta plantilla en el espacio principal."
end
local params = {
[1] = {},
["t"] = {lista = true},
["trad"] = {alias_de = "t"},
["traduccion"] = {alias_de = "t"},
["traducción"] = {alias_de = "t"},
["d"] = {alias_de = "t"},
["desc"] = {alias_de = "t"},
["descendiente"] = {alias_de = "t"},
["a"] = {lista = true},
["acepcion"] = {alias_de = "a"},
["acepción"] = {alias_de = "a"},
["niv"] = {tipo = "num", por_defecto = 1},
["nivel"] = {alias_de = "niv"},
["nl"] = {lista = true}, -- no lo hago binario porque primero tengo que separar las / barras
["nolink"] = {alias_de = "nl"},
["nota"] = {lista = true},
["tl"] = {lista = true},
["tr"] = {alias_de = "tl"},
["transliteración"] = {alias_de = "tl"},
["transliteracion"] = {alias_de = "tl"},
["g"] = {lista = true},
["genero"] = {alias_de = "g"},
["género"] = {alias_de = "g"},
["n"] = {lista = true},
["numero"] = {alias_de = "n"},
["número"] = {alias_de = "n"},
["c"] = {lista = true},
["cat"] = {alias_de = "c"},
["categoria"] = {alias_de = "c"},
["categoría"] = {alias_de = "c"},
["caso"] = {lista = true},
["m"] = {lista = true},
["modo"] = {alias_de = "m"},
["r"] = {lista = true},
["relacion"] = {alias_de = "r"},
["relación"] = {alias_de = "r"},
["ne"] = {lista = true}, -- no lo hago binario porque primero tengo que separar las / barras
["noequivalente"] = {alias_de = "ne"},
["i"] = {lista = true}, -- no lo hago binario porque primero tengo que separar las / barras
["inc"] = {alias_de = "i"},
["incompleto"] = {alias_de = "i"},
["incompleta"] = {alias_de = "i"},
["na"] = {tipo = "binario"},
["noaplica"] = {alias_de = "na"},
["f"] = {tipo = "binario"},
["falta"] = {alias_de = "f"},
}
local parent_frame = frame:getParent()
local args = require("Módulo:parámetros").obtener_parametros(parent_frame.args, params)
if not args[1] then
error("Se requiere especificar el código de idioma")
end
local cod = args[1]
local COD = cod:upper()
local idioma
if categorizar then
idioma = obtener_idioma(cod)
else
idioma = obtener_idioma(cod, true)
if not idioma then
idioma = obtener_familia(cod)
end
assert(idioma ~= nil)
end
local nombre = ucfirst(idioma[1])
local ns = mw.title.getCurrentTitle().namespace
--local tit = mw.title.getCurrentTitle().fullText
local t = {}
insert(t, string.rep(":", args["niv"]-1))
insert(t, "*")
insert(t, " "..nombre..": ")
if args["f"] then
return concat(t).."''falta''"
elseif args["na"] then
return concat(t).."''no aplica''"
end
local determinar_genero = {
['m'] = "''masculino''",
['f'] = "''femenino''",
['mf'] = "''masculino y femenino''",
['mn'] = "''masculino y neutro''",
['fn'] = "''femenino y neutro''",
['mfn'] = "''masculino, femenino y neutro''",
['n'] = "''neutro''",
['c'] = "''común''",
['cn'] = "''común, neutro''",
}
local determinar_numero = {
['s'] = "''singular''",
['sg'] = "''singular''",
['p'] = "''plural''",
['pl'] = "''plural''",
['d'] = "''dual''",
['du'] = "''dual''",
}
local determinar_caso = {
["ab"] = "''ablativo''",
["ac"] = "''acusativo''",
["ad"] = "''adesivo''",
["as"] = "''absolutivo''",
["av"] = "''aversivo''",
["da"] = "''dativo''",
["el"] = "''elativo''",
["ge"] = "''genitivo''",
["il"] = "''ilativo''",
["in"] = "''instrumental''",
["lo"] = "''locativo''",
["no"] = "''nominativo''",
["vo"] = "''vocativo''",
}
local determinar_relacion = {
["co"] = "''comparativo''",
["su"] = "''superlativo''",
["au"] = "''aumentativo''",
["di"] = "''diminutivo''",
}
local determinar_cat = {
['s'] = "''sustantivo''",
['a'] = "''adjetivo''",
['v'] = "''verbo''",
['sa'] = "''sustantivo y adjetivo''",
['sv'] = "''sustantivo y verbo''",
['av'] = "''adjetivo y verbo''",
['sav'] = "''sustantivo, adjetivo y verbo''",
}
local function iteracion(i)
if args["a"][i] then
insert(t, "["..args["a"][i].."] ")
end
local trads = strsplit(args["t"][i] and args["t"][i] or "", "%s*/%s*")
local tl = strsplit(args["tl"][i] and args["tl"][i] or "", "%s*/%s*")
local c = strsplit(args["c"][i] and args["c"][i] or "", "%s*/%s*")
local g = strsplit(args["g"][i] and args["g"][i] or "", "%s*/%s*")
local n = strsplit(args["n"][i] and args["n"][i] or "", "%s*/%s*")
local caso = strsplit(args["caso"][i] and args["caso"][i] or "", "%s*/%s*")
local r = strsplit(args["r"][i] and args["r"][i] or "", "%s*/%s*")
local ne = strsplit(args["ne"][i] and args["ne"][i] or "", "%s*/%s*")
local inc = strsplit(args["i"][i] and args["i"][i] or "", "%s*/%s*")
local nl = strsplit(args["nl"][i] and args["nl"][i] or "", "%s*/%s*")
local nota = strsplit(args["nota"][i] and args["nota"][i] or "", "%s*/%s*")
for j,trad in ipairs(trads) do
if j > 1 then
insert(t, ", ")
end
if booleano(nl[j], false) then
insert(t, trad)
else
insert(t, "[["..trad.."#"..nombre.."|"..trad.."]]")
end
if booleano(inc[j], false) then
insert(t, "<abbr title=\"traducción incompleta o dudosa\">?</abbr>")
insert(t, "[[Categoría:"..COD..":Traducciones incompletas o imprecisas]]")
end
if booleano(ne[j], false) then
insert(t, "<abbr title=\"la traducción no es exacta ni idiomática\">~</abbr>")
end
insert(t, " <sup>[[:"..cod..":"..trad.."|("..cod..")]]</sup>")
if tl[j] and tl[j] ~= "" then
insert(t, " “"..tl[j].."”")
end
local t2 = {}
if c[j] and c[j] ~= "" then
local c_ = determinar_cat[c[j]]
assert(c_, "categoría gramatical incorrecta: "..c[j])
insert(t2, c_)
end
if g[j] and g[j] ~= "" then
local g_ = determinar_genero[g[j]]
assert(g_, "género incorrecto: "..g[j])
insert(t2, g_)
end
if n[j] and n[j] ~= "" then
local n_ = determinar_numero[n[j]]
assert(n_, "número incorrecto: "..n[j])
insert(t2, n_)
end
if caso[j] and caso[j] ~= "" then
local caso_ = determinar_caso[caso[j]]
assert(caso_, "caso incorrecto: "..caso_)
insert(t2, caso_)
end
if r[j] and r[j] ~= "" then
local r_ = determinar_relacion[r[j]]
assert(r_, "relación incorrecta: "..r_)
insert(t2, r_)
end
if nota[j] and nota[j] ~= "" then
insert(t2, nota[j])
end
if #t2 > 0 then
insert(t, " ("..concat(t2, ", ")..")")
end
end
end
if args["t"][1] then
iteracion(1)
if ns == 0 and categorizar then
insert(t, "[[Categoría:Español-"..nombre.."]]")
end
end
for i=2, #args["t"] do
insert(t, "; ")
iteracion(i)
end
return concat(t)
end
function export.mostrar(frame)
return mostrar_(frame, true)
end
function export.mostrar_sin_categorizar(frame)
return mostrar_(frame, false)
end
return export