Modul:descendants
Roman
Dokumentasi untuk modul ini dapat dibuat di Modul:descendants/doc
local p = {}
local langModule = require('Modul:lang')
local mwhtml = mw.html
-- Render a single descendant
-- Usage: {{#invoke:descendants|desc|lang|term|der=1|bor=0|inh=0|unc=0|t=…|tr=…|id=…|q=…}}
function p.desc(frame)
local args = frame.args or {}
local lang = args[1] or ""
local term = args[2] or ""
local der = args.der
local bor = args.bor
local inh = args.inh
local unc = args.unc
local t = args.t or ""
local tr = args.tr or ""
local id = args.id or ""
local q = args.q or ""
-- If unc appears alone, treat as inh+unc
if unc and not (der or bor or inh) then
inh = true
end
local fullLangName = langModule.getLangName({ args = {[1]=lang} }) or lang
-- Determine symbol and tooltip
local symbol = ""
local tooltip = ""
if der then
symbol = "⇒"
tooltip = "Turunan kaga' langsung ke " .. fullLangName
elseif bor then
symbol = "→"
tooltip = "Pinjeman ke " .. fullLangName
elseif inh or unc then
symbol = ">"
tooltip = "Terusan ke " .. fullLangName
end
-- Build HTML span
local html = mwhtml.create("span"):addClass("descendant"):css("font-size","95%")
if symbol ~= "" then
html:node(
mwhtml.create("span")
:attr("title", tooltip)
:wikitext(symbol)
)
end
if unc then
html:node(
mwhtml.create("sup")
:attr("title", "ora puguh")
:wikitext("?")
)
end
if symbol ~= "" or unc then
html:wikitext(" ")
end
-- Language + optional term
html:wikitext("{{lang|" .. lang .. "}}")
if term ~= "" then
html:wikitext(": {{l|" .. lang .. "|" .. term)
if t ~= "" then html:wikitext("|t=" .. t) end
if tr ~= "" then html:wikitext("|tr=" .. tr) end
if id ~= "" then html:wikitext("|id=" .. id) end
if q ~= "" then html:wikitext("|q=" .. q) end
html:wikitext("}}")
end
return tostring(html)
end
return p