Modul:etymology/templates/internal: Perbezaan antara semakan

Kandungan dihapus Kandungan ditambah
PeaceSeekers (bincang | sumb.)
Tiada ringkasan suntingan
Hakimi97 (bincang | sumb.)
Mengemas kini fungsi modul seperti di Wikikamus bahasa Inggeris
Teg: Dibalikkan
Baris 1:
-- For internal use only with [[Module:etymology/templates]] and its submodules.
local process_params = require("Module:parameters").process
 
local export = {}
Baris 6 ⟶ 7:
return require("Module:languages").getByCode(lang, param)
end
 
 
function export.fetch_source(code, param, disallow_family)
return require("Module:languages").getByCode(code, param, true, not disallow_family)
end
 
 
local function fetch_sources(codes, param, disallow_family)
local m_languages = require("Module:languages")
codes = mw.text.split(codes, "%s*,%s*")
for i, code in ipairs(codes) do
codes[i] = m_languages.getByCode(code, param, true, not disallow_family)
end
return codes
end
 
 
function export.fetch_source_or_sources(source, param, disallow_family)
local sources
if source:find(",") then
sources = fetch_sources(source, param, disallow_family)
source = sources[#sources]
else
source = export.fetch_source(source, param, disallow_family)
end
return source, sources
end
 
 
function export.fetch_script(sc, param)
Baris 39 ⟶ 16:
end
 
do
 
local function export.parse_2_lang_argsget_params(frame, has_text, no_family)
local paramsalias_of_t = {alias_of = "t"}
local boolean = {type = "boolean"}
[1] = true,
[2]local plain = true,{}
[3]local params = false,{
[1] = {
required = true,
["alt"] = {aliases = {4}},
["cat"] type = false"language",
["id"] default = false,"und"
},
["lit"] = false,
["pos"2] = false,{
required = true,
["t"] = {aliases = {5, "gloss"}},
["tr"] sublist = falsetrue,
["ts"] type = false"language",
["sc"] etym_lang = falsetrue,
family = not no_family,
["senseid"] = false,
default = "und"
 
},
["nocat"] = false,
["sort"3] = falseplain,
["conj"4] = false{alias_of = "alt"},
[5] = alias_of_t,
}
 
["alt"] = plain,
if has_text then
params ["notextcat"] = falseplain,
params ["nocapg"] = false{list = true},
["gloss"] = alias_of_t,
["id"] = plain,
["lit"] = plain,
["pos"] = plain,
["t"] = plain,
["tr"] = plain,
["ts"] = plain,
["sc"] = {type = "script"},
["senseid"] = plain,
["nocat"] = boolean,
["sort"] = plain,
["conj"] = plain,
}
if has_text then
params["notext"] = boolean
params["nocap"] = boolean
end
return process_params(frame:getParent().args, params)
end
 
function export.parse_2_lang_args(frame, has_text, no_family)
local args = require("Module:parameters/lite").process(frame:getParent().args, params)
local yesnoargs = requireget_params("Module:yesno"frame, has_text, no_family)
local sources = args[2]
 
return args, args[1], {
args["g"] = require("Module:parameters/lite/list")(frame:getParent().args, "g")
lang = sources[#sources],
args["nocat"] = yesno(args["nocat"])
sc = args["sc"],
if has_text then
args["notext"] term = yesno(args["notext"3]),
args["nocap"] alt = yesno(args["nocapalt"]),
id = args["id"],
genders = args["g"],
tr = args["tr"],
ts = args["ts"],
gloss = args["t"],
pos = args["pos"],
lit = args["lit"]
}, #sources > 1 and sources or nil
end
local lang = export.fetch_lang(args[1], 1)
local source, sources = export.fetch_source_or_sources(args[2], 2, no_family)
local sc = export.fetch_script(args["sc"], "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"]
}, sources
end