Modul:links/templates
l_term_t ännern
{{#invoke:links|l_term_t}}
This is called by the templates {{l}}
and {{term}}
. It gathers the template parameters and then calls full_link
which does most of the work.
local m_links = require("Modul:links")
local export = {}
-- Used in [[Template:l]] and [[Template:term]]
function export.l_term_t(frame)
local face = frame.args["face"]; if face ~= "term" then face = nil end
local notself = frame.args["notself"]; if notself == "" then notself = nil end
-- Compatibility mode.
-- If given a nonempty value, the function uses lang= to specify the
-- language, and all the positional parameters shift one number lower.
local compat = (frame.args["compat"] or "") ~= ""
local args = frame:getParent().args
local lang = args[(compat and "lang" or 1)]; if lang == "" then lang = nil end
local sc = args["sc"]; if sc == "" then sc = nil end
local term = args[(compat and 1 or 2)]; if term == "" then term = nil end
local alt = args[(compat and 2 or 3)]; if alt == "" then alt = nil end
local id = args["id"]; if id == "" then id = nil end
local tr = args["tr"]; if tr == "" then tr = nil end
local gloss = args["gloss"] or args[(compat and 3 or 4)]; if gloss == "" then gloss = nil end
local pos = args["pos"]; if pos == "" then pos = nil end
local lit = args["lit"]; if lit == "" then lit = nil end
-- Gather gender and number specifications
-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
local genders = {}
local g = args["g"] or ""
local i = 2
while g ~= "" do
table.insert(genders, g)
g = args["g" .. i] or ""
i = i + 1
end
-- Check parameters
if not lang then
-- Temporary. Unfortunately, many pages are missing the language parameter.
-- These all need to be fixed, but until then this is needed to avoid
-- thousands of script errors. See [[:Category:term cleanup]]!
if compat or mw.title.getCurrentTitle().nsText == "Vörlaag" then
lang = "und"
else
error("The first parameter (language code) has not been given")
end
end
lang = require("Modul:languages").getByCode(lang) or error("De Spraakkod \"" .. lang .. "\" is nich gültig.")
sc = (sc and (require("Modul:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
if not term and not alt and mw.title.getCurrentTitle().nsText == "Vörlaag" then
term = "term"
end
-- Forward the information to full_link
return m_links.full_link(term, alt, lang, sc, face, id, {tr = tr, genders = genders, gloss = gloss, pos = pos, lit = lit}, (notself and mw.title.getCurrentTitle().prefixedText or nil))
end
return export