Module:etymology/templates/internal
Documentation for this module may be created at Module:etymology/templates/internal/doc
-- For internal use only with [[Module:etymology/templates]] and its submodules.
local export = {}
function export.fetch_lang(lang, parameter)
local m_languages = require("Module:languages")
return m_languages.getByCode(lang) or m_languages.err(lang, parameter)
end
function export.fetch_source(code, disallow_family)
local m_languages = require("Module:languages")
local source =
m_languages.getByCode(code)
or require("Module:etymology languages").getByCode(code)
or not disallow_family and require("Module:families").getByCode(code)
if source then
return source
else
error("The language" .. (not disallow_family and ", family" or "") .. " or etymology language code \"" .. code .. "\" is not valid.")
end
end
function export.fetch_script(sc)
if sc then
return require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
else
return nil
end
end
function export.parse_2_lang_args(frame, has_text, no_family)
local params = {
[1] = {required = true, default = "und"},
[2] = {required = true, default = "und"},
[3] = {},
[4] = {alias_of = "alt"},
[5] = {alias_of = "t"},
["alt"] = {},
["g"] = {list = true},
["gloss"] = {alias_of = "t"},
["id"] = {},
["lit"] = {},
["pos"] = {},
["t"] = {},
["tr"] = {},
["ts"] = {},
["sc"] = {},
["nocat"] = {type = "boolean"},
["sort"] = {},
}
if has_text then
params["notext"] = {type = "boolean"}
params["nocap"] = {type = "boolean"}
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = export.fetch_lang(args[1], 1)
local source = export.fetch_source(args[2], no_family)
local sc = export.fetch_script(args["sc"])
return args, lang, {
lang = source,
sc = sc,
term = args[3],
alt = args["alt"],
id = args["id"],
genders = args["g"],
tr = args["tr"],
ts = args["ts"],
gloss = args["t"],
pos = args["pos"],
lit = args["lit"]
}
end
return export