Модул:descendants tree/templates
Script error: The function "main" does not exist.
local export = {}
local m_languages = require("Модул: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" },
["bor"] = { type = "boolean" },
["der"] = { type = "boolean" },
["q"] = {},
["sandbox"] = { type = "boolean" }
}
local args
if frame.args[1] then
args = require("Модул:parameters").process(frame.args, params)
else
args = require("Модул:parameters").process(frame:getParent().args, params)
end
if args.sandbox then
local namespace = mw.title.getCurrentTitle().nsText
if namespace == "" or namespace == "Реконструкција" then
error('The sandbox module, Модул:descendants tree/sandbox, should not be used in entries.')
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("Модул:etymology languages").getByCode(lang)
or m_languages.err(lang, 1)
local entryLang = require("Модул:etymology").getNonEtymological(lang)
if lang:getCode() ~= entryLang:getCode() then
-- [[Special:WhatLinksHere/Шаблон:tracking/descendant/etymological]]
require("Модул:debug").track("descendant/etymological")
require("Модул:debug").track("descendant/etymological/" .. lang:getCode())
end
if sc then
sc = require("Модул:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
end
local languageName = lang:getCanonicalName()
languageName = mw.ustring.gsub(languageName, "^Пра%-", "")
local descendants, alts, arrow, prefix, qual
local m_desctree
if args.sandbox or require("Модул:yesno")(frame.args.sandbox, false) then
m_desctree = require("Модул:descendants tree/sandbox")
else
m_desctree = require("Модул: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("Модул: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 = "⇒ "
else
arrow = ""
end
if args["notext"] then
prefix = ""
else
prefix = table.concat{arrow, languageName, ": "}
end
if args["q"] then
qual = " " .. require("Модул:qualifier").format_qualifier(args["q"])
else
qual = ""
end
return table.concat{prefix, link, alts or "", qual, descendants}
end
return export