Módulo:t+
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 obtener_idioma = require("Módulo:lenguas").cod_a_idioma
local generar_error = require("Módulo:traza")
function export.mostrar(frame)
local ns = mw.title.getCurrentTitle().namespace
--local tit = mw.title.getCurrentTitle().fullText
local idioma
local cod
local COD
local nombre
local args = frame:getParent().args
local t = {}
local tabla = {
['m.'] = " (<abbr title=\"masculino\">''m.''</abbr>)",
['f.'] = " (<abbr title=\"femenino\">''f.''</abbr>)",
['mf.'] = " (<abbr title=\"masculino y femenino\">''m., f.''</abbr>)",
['n.'] = " (<abbr title=\"neutro\">''n.''</abbr>)",
['c.'] = " (<abbr title=\"común\">''c.''</abbr>)",
['p.'] = " (<abbr title=\"plural\">''pl.''</abbr>)",
['s.'] = " (<abbr title=\"sustantivo\">''sust.''</abbr>)",
['a.'] = " (<abbr title=\"adjetivo\">''adj.''</abbr>)",
['v.'] = " (<abbr title=\"verbo\">''verb.''</abbr>)",
['sa.'] = " (<abbr title=\"sustantivo y adjetivo\">''sust. y adj.''</abbr>)",
['sv.'] = " (<abbr title=\"sustantivo y verbo\">''sust. y verb.''</abbr>)",
['av.'] = " (<abbr title=\"adjetivo y verbo\">''adj. y verb.''</abbr>)",
['sav.'] = " (<abbr title=\"sustantivo, adjetivo y verbo\">''sust., adj. y verb.''</abbr>)",
[','] = ','
}
local equiv = {
['m'] = 'm.',
['f'] = 'f.',
['mf'] = 'mf.',
['n'] = 'n.',
['c'] = 'c.',
['s'] = 's.',
['a'] = 'a.',
['v'] = 'v.',
['sa'] = 'sa.',
['sv'] = 'sv.',
['av'] = 'av.',
['sav'] = 'sav.',
['adj.'] = 'a.',
['adj'] = 'a.',
['sust'] = 's.',
['sust.'] = 's.',
['verb'] = 'v.',
['verb.'] = 'v.',
['adj. & sust'] = 'sa.',
['adj. & sust.'] = 'sa.',
['adj & sust'] = 'sa.',
['adj & sust.'] = 'sa.',
['adj. y sust'] = 'sa.',
['adj. y sust.'] = 'sa.',
['adj y sust'] = 'sa.',
['adj y sust.'] = 'sa.',
['sust. & adj'] = 'sa.',
['sust. & adj.'] = 'sa.',
['sust & adj'] = 'sa.',
['sust & adj.'] = 'sa.',
['sust y adj'] = 'sa.',
['sust. y adj.'] = 'sa.',
['sust. y adj'] = 'sa.',
['sust y adj.'] = 'sa.',
['verb. & sust'] = 'sv.',
['verb. & sust.'] = 'sv.',
['verb & sust'] = 'sv.',
['verb & sust.'] = 'sv.',
['verb. y sust'] = 'sv.',
['verb. y sust.'] = 'sv.',
['verb y sust'] = 'sv.',
['verb y sust.'] = 'sv.',
['sust. & verb'] = 'sv.',
['sust. & verb.'] = 'sv.',
['sust & verb'] = 'sv.',
['sust & verb.'] = 'sv.',
['sust y verb'] = 'sv.',
['sust. y verb.'] = 'sv.',
['sust. y verb'] = 'sv.',
['sust y verb.'] = 'sv.',
['nl'] = 'nl.',
['nota'] = 'obs.',
['tr'] = 'tr.'
}
local function parte(a_, b_)
local z = substr(a_, 1, 1)
if z >= '0' and z <= '9' then
insert(t, " ["..a_.."]")
return
end
local a, b = equiv[a_], equiv[b_]
if a then
generar_error('tmal')
else
a = a_
end
if b then
generar_error('tmal')
else
b = b_
end
if b == 'nl.' then
insert(t, " "..a)
return
elseif b == 'obs.' then
insert(t, " ("..a..")")
return
elseif b == 'tr.' then
insert(t, " (''"..a.."'')")
return
end
if a == 'nl.' or a == 'obs.' or a == 'tr.' then
return
end
local x = tabla[a]
if x then
insert(t, x)
else
insert(t, " [["..a.."#"..nombre.."|"..a.."]]".." <sup>[[:"..cod..":"..a.."|("..cod..")]]</sup>")
end
end
local tr = args["tr"]
local prev
if tr then
generar_error("tr")
end
for i,arg in ipairs(args) do
if i == 1 then
idioma = obtener_idioma(arg)
cod = arg
COD = arg:upper()
tabla['?'] = " (?)[[Categoría:"..COD..":Traducciones incompletas o imprecisas]]"
nombre = ucfirst(idioma[1])
insert(t, "* "..nombre..":")
elseif i == 2 or i == 3 then
parte(arg, prev)
if tr and not (substr(arg, 1, 1) >= '0' and substr(arg, 1, 1) <= '9') then
parte(tr, 'tr')
tr = nil
end
prev = arg
else
parte(arg, prev)
prev = arg
end
end
if ns == 0 and prev then --si hay prev, al menos se invocó con un argumento
insert(t, "[[Categoría:Español-"..nombre.."]]")
end
return concat(t)
end
return export