Module:etymology/templates: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 32: Line 32:




local function fetch_script(sc)
local function fetch_script(sc, source)
if sc then
if sc then
return require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
return require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
else
else
return nil
return require("Module:scripts").getByCode(sc)
end
end
end
end
Line 94: Line 94:
local source = fetch_source(args[1])
local source = fetch_source(args[1])
local sc = fetch_script(args["sc"])
local sc = fetch_script(args["sc"], source)


return m_etymology.format_cognate(
return m_etymology.format_cognate(
Line 150: Line 150:
local lang = fetch_lang(args[1], 1)
local lang = fetch_lang(args[1], 1)
local source = fetch_source(args[2], no_family)
local source = fetch_source(args[2], no_family)
local sc = fetch_script(args["sc"])
local sc = fetch_script(args["sc"], source)


return args, lang, {
return args, lang, {
Line 163: Line 163:
gloss = args["t"],
gloss = args["t"],
pos = args["pos"],
pos = args["pos"],
lit = args["lit"]
lit = args["lit"],
nocont = true,
}
}
end
end
Line 359: Line 360:
local languageName = lang:getCanonicalName()
local languageName = lang:getCanonicalName()
languageName = mw.ustring.gsub(languageName, "^Proto%-", "")
local link = ""
local link = ""
Line 393: Line 396:
:gsub("<small>%[Term%?%]</small>&nbsp;", "")
:gsub("<small>%[Term%?%]</small>&nbsp;", "")
:gsub("%[%[Category:[^%[%]]+ term requests%]%]", "")
:gsub("%[%[Category:[^%[%]]+ term requests%]%]", "")
else -- display no link at all
end
end
Line 415: Line 417:
arrow = add_tooltip("→", "borrowed")
arrow = add_tooltip("→", "borrowed")
elseif args["lbor"] then
elseif args["lbor"] then
arrow = add_tooltip("→", "learned borrowing")
arrow = add_tooltip("→", "learned borrowed")
elseif args["slb"] then
elseif args["slb"] then
arrow = add_tooltip("→", "semi-learned borrowing")
arrow = add_tooltip("→", "semi-learned borrowing")
Line 512: Line 514:
function export.descendant(frame)
function export.descendant(frame)
return desc_or_desc_tree(frame, false) .. require("Module:TemplateStyles")("Module:etymology/style.css")
return desc_or_desc_tree(frame, false) .. require("Module:TemplateStyles")("Template:descendant/style.css")
end
end


Line 567: Line 569:
local lang = fetch_lang(args[1], 1)
local lang = fetch_lang(args[1], 1)
local sc = fetch_script(args["sc"])
local sc = fetch_script(args["sc"], lang)


local parts = {}
local parts = {}
Line 634: Line 636:
local g = args["g"][i]
local g = args["g"][i]


if not (term or alt or tr or ts) then
if term or alt or tr or ts then
return nil
else
return require("Module:links").full_link(
return require("Module:links").full_link(
{ term = term, alt = alt, id = id, lang = lang, sc = sc, tr = tr,
{ term = term, alt = alt, id = id, lang = lang, sc = sc, tr = tr,