Modul:descendants tree/templates
Dokumentasi untuk modul ini dapat dibuat di Modul:descendants tree/templates/doc
local export = {}
local qualifier -- defined below
local m_languages = require("Module:languages")
function export.show(frame)
local params = {
[1] = {required = true, default = "gem-pro"},
[2] = {required = true, default = "*fuhsaz"},
[3] = {},
[4] = {alias_of = "gloss"},
["g"] = {list = true},
["gloss"] = {},
["t"] = {alias_of = "gloss"},
["id"] = {},
["lit"] = {},
["pos"] = {},
["tr"] = {},
["ts"] = {},
["sc"] = {},
["notext"] = { type = "boolean" },
["noalts"] = { type = "boolean" },
["noparent"] = { type = "boolean" },
["bor"] = { type = "boolean" },
["der"] = { type = "boolean" },
["clq"] = { type = "boolean" },
["cal"] = { alias_of = "clq" },
["calq"] = { alias_of = "clq" },
["calque"] = { alias_of = "clq" },
["q"] = {},
["sandbox"] = { type = "boolean" }
}
local args
if frame.args[1] then
args = require("Module:parameters").process(frame.args, params)
else
args = require("Module:parameters").process(frame:getParent().args, params)
end
if args.sandbox then
local namespace = mw.title.getCurrentTitle().nsText
if namespace == "" or namespace == "Rekonstruksi" then
error('Module:descendants tree/sandbox adalah modul bak pasir dan tidak dipergunakan pada lema.')
end
end
local lang = args[1]
local term = args[2]
local alt = args[3]
local sc = args["sc"]
local id = args["id"]
lang = m_languages.getByCode(lang)
or require("Module:etymology languages").getByCode(lang)
or m_languages.err(lang, 1)
local entryLang = require("Module:etymology").getNonEtymological(lang)
if lang:getCode() ~= entryLang:getCode() then
-- [[Special:WhatLinksHere/Template:tracking/descendant/etymological]]
require("Module:debug").track("descendant/etymological")
require("Module:debug").track("descendant/etymological/" .. lang:getCode())
end
if sc then
sc = require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
end
local descendants, alts, arrow, calque, qual
local m_desctree
if args.sandbox or require("Module:yesno")(frame.args.sandbox, false) then
m_desctree = require("Module:descendants tree/sandbox")
else
m_desctree = require("Module:descendants tree")
end
descendants = m_desctree.getDescendants(entryLang, term, id)
if not args["noalts"] then
alts = m_desctree.getAlternativeForms(entryLang, term)
end
local link = require("Module:links").full_link(
{
lang = entryLang,
sc = sc,
term = args[2],
alt = args[3],
id = args["id"],
tr = args["tr"],
ts = args["ts"],
genders = args["g"],
gloss = args["gloss"],
pos = args["pos"],
lit = args["lit"],
},
nil,
true
)
if args["bor"] then
arrow = "→ "
elseif args["der"] then
arrow = "⇒ "
elseif args["clq"] then
arrow = "→ "
else
arrow = ""
end
if args["clq"] then
calque = " " .. qualifier("calque")
else
calque = ""
end
if args["q"] then
qual = " " .. require("Module:qualifier").format_qualifier(args["q"])
else
qual = ""
end
if args["noparent"] then
return descendants
else
local prefix
if args["notext"] then
prefix = ""
else
local languageName = lang:getCanonicalName()
languageName = mw.ustring.gsub(languageName, "^Proto%-", "")
prefix = arrow .. languageName .. ": "
end
return table.concat{prefix, link, alts or "", calque, qual, descendants}
end
end
function qualifier(content)
if content then
return table.concat{
'<span class="ib-brac qualifier-brac">(</span>',
'<span class="ib-content qualifier-content">',
content,
'</span>',
'<span class="ib-brac qualifier-brac">)</span>'
}
end
end
return export