Modulo:lighi/modełi
La documentazione per questo modulo può essere creata in Modulo:lighi/modełi/man
--DA CA.WIKT--
local m_lengua = require("Module:łéngua")
local m_links = require("Module:lighi")
local p = {}
-- Funció d'entrada per la Modeło:e
function p.modelo_e(frame)
local args = frame:getParent().args
local lang = args[1]
if not m_lengua.existeix(lang) then
error("El còdaze de lengua \"" .. lang .. "\" no ze vàłido.")
end
local term = args[2]
local alt = args[3] or ""; if alt == "" then alt = nil end
local allowSelfLink = args["notself"] or frame.args["notself"]
allowSelfLink = not allowSelfLink or allowSelfLink == ""
-- Forward the information to full_link
return m_links.full_link({langcode = lang, sc = args["sc"], term = term, alt = alt, id = args["id"], tr = args["tr"], genders = {args["g"]}, gloss = args["glossa"], pos = args["pos"], lit = args["lit"]}, nil, allowSelfLink)
end
-- Funció d'entrada per la Modeło:terme
function p.modelo_terme(frame)
local args = frame:getParent().args
local lang = args[1]
local term = args[2]; if term == "" then term = nil end
if not m_lengua.existeix(lang) then
error("El còdaze de lengua \"" .. lang .. "\" no ze vàłido.")
end
local alt = args[3] or ""; if alt == "" then alt = nil end
local trad = args["trad"]; if trad == "" then trad = nil end
local lit = args["lit"]; if lit == "" then lit = nil end
local sc = args["sc"]; if sc == "" then sc = nil end
local trans = args["trans"]; if trans == "" then trans = nil end
-- Forward the information to full_link
return m_links.full_link({langcode = lang, sc = sc, term = term, alt = alt, id = args["id"], tr = trans, genders = {args["g"]}, gloss = trad, pos = args["pos"], lit = lit}, "terme", true)
end
-- Funció d'entrada per la Modeło:trad. Original: en:Module:translations
function p.trad(frame)
local args = frame:getParent().args
local terminfo = {
langcode = args[1],
sc = args["sc"] or nil,
term = mw.text.trim(args[2]) or (mw.title.getCurrentTitle().nsText == "Modeło" and "terme") or nil,
alt = args["alt"] or nil,
genders = {args[3]} or nil,
tr = args["tr"] or nil,
}
-- Don't show the interwiki link if there is nothing to link to.
if terminfo.term then
local wmlang = m_lengua.wmproject(terminfo.langcode)
-- Don't show the interwiki link if the language is not recognised by Wikimedia
-- or if the term contains links (for SOP translations)
if wmlang == nil or terminfo.term:find("[[", nil, true) then
terminfo.interwiki = " <sup><small><span style='color:#bbbbbb'>(" .. terminfo.langcode .. ")</span></small></sup>"
else
terminfo.interwiki = " [[:" .. wmlang .. ":" .. m_links.sense_diacritics(terminfo.langcode, terminfo.term) .. "|<sup><small>(" .. wmlang .. ")</small></sup>]]"
end
return m_links.full_link(terminfo, "trad", true)
end
return '<span style="background-color: #f0fff0; font-style:italic;">zonta na tradusion</span>[[Categoria:Tradusion dimandada ' .. m_lengua.nom(lang) .. ']]'
end
-- Funció d'entrada per la Modeło:leng
function p.modelo_leng(frame)
local args = frame:getParent().args
local lang = args[1]; if lang == "" then lang = nil end
local text = args[2] or ""
local face = args["tipus"]; if face == "" then face = nil end
NAMESPACE = mw.title.getCurrentTitle().nsText
lang = lang or (NAMESPACE == "Modeło" and "vec") or error("Manca spesifegasion del còdaze de łéngua")
if not m_lengua.existeix(lang) then error("Còdaze de łéngua incoreto") end
local sc = args["sc"] or m_lengua.script(lang)
return m_links.tag_text(text, lang, sc, face)
end
-- Temporary stopgap measure to fix [[Template:isValidPageName]].
function p.isValidPageName(frame)
local res = mw.title.new(frame.args[1])
if res then
return "valid"
else
return ""
end
end
return p