Modul:etimolociye/şablon
Seba na module şıma şenê yû pela dokumani vırazê Modul:etimolociye/şablon/dok
local export = {}
local m_languages = require("Modul:languages")
local b = require("Modul:bases")
local rsplit = mw.text.split
local rsubn = mw.ustring.gsub
-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
local retval = rsubn(term, foo, bar)
return retval
end
local function fetch_lang(lang, parameter)
return m_languages.getByCode(lang) or m_languages.err(lang, parameter)
end
local function fetch_source(code, disallow_family)
local source =
m_languages.getByCode(code)
or require("Modul:etymology languages").getByCode(code)
or not disallow_family and require("Modul:families").getByCode(code)
if source then
return source
else
error("Koda zimanê" .. (not disallow_family and ", malbata" or "") .. " yan zimanê etîmolojiyê \"" .. code .. "\" nayê zanîn.")
end
end
local function fetch_script(sc)
if sc then
return require("Modul:scripts").getByCode(sc) or error("Koda skrîptê \"" .. sc .. "\" nayê zanîn.")
else
return nil
end
end
function export.cognate(frame)
local args = frame:getParent().args
local params = {
[1] = {required = true, default = "und"},
[2] = {},
[3] = {alias_of = "ser"},
[4] = {alias_of = "m"},
["cuda"] = {},
["m"] = {},
["mane"] = {alias_of = "m"},
["tr"] = {},
["ts"] = {},
["sc"] = {},
["sort"] = {},
}
args = require("Modul:parameters").process(args, params)
local source = fetch_source(args[1])
local sc = fetch_script(args["sc"])
return require("Modul:etimolociye").format_cognate(
{
lang = source,
sc = sc,
term = args[2],
alt = args["ser"],
tr = args["tr"],
ts = args["ts"],
gloss = args["m"],
},
args["sort"])
end
function export.nehevreh(frame)
return export.hevreh(frame)
end
local function parse_2_lang_args(frame, has_text, no_family)
local params = {
[1] = {required = true, default = "und"},
[2] = {default = "diq"},
[3] = {},
[4] = {alias_of = "ser"},
[5] = {alias_of = "m"},
["ser"] = {},
["mane"] = {alias_of = "m"},
["m"] = {},
["tr"] = {},
["ts"] = {},
["sc"] = {},
["sort"] = {},
}
if has_text then
params["notext"] = {type = "boolean"}
params["nocap"] = {type = "boolean"}
end
local args = require("Modul:parameters").process(frame:getParent().args, params)
local lang = fetch_lang(args[2], 1)
local source = fetch_source(args[1], no_family)
local sc = fetch_script(args["sc"])
return args, lang, {
lang = source,
sc = sc,
term = args[3],
alt = args["cuda"],
tr = args["tr"],
ts = args["ts"],
gloss = args["m"]
}
end
function export.from(frame)
local args, lang, term = parse_2_lang_args(frame)
return require("Modul:etimolociye").format_derived(lang, term, args["sort"])
end
function export.inherited(frame)
local args, lang, term = parse_2_lang_args(frame, nil, "no family")
return require("Modul:etimolociye").format_inherited(lang, term, args["sort"])
end
function export.borrowed(frame)
local args, lang, term = parse_2_lang_args(frame)
return require("Modul:etimolociye").format_borrowed(lang, term, args["sort"],
false, true, "plain")
end
local 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