Modul:cetusan
Implementasikan {{cetusan}}
.
local export = {}
local m_utilities = require("Module:utilities")
local m_languages = require("Modul:languages")
function export.cetusan(frame)
local args = frame:getParent().args
local params = {
[1] = {required = true, default = "und"},
[2] = {required = true, default = "tak diketahui"},
["th"] = {}, -- date: "pada tahun"
["w"] = {default = nil}, -- target tautan Wikipedia
["kebangsaan"] = {}, -- kebangsaan
["pekerjaan"] = {list = true, default = nil},
["alt"] = {default = nil}, -- kebangsaan
["keb"] = {},
["pek"] = {list = true, default = nil},
["sort"] = {},
["nobycat"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
["nocap"] = {type = "boolean"},
["notext"] = {type = "boolean"},
}
args = require("Module:parameters").process(args, params)
local lang = m_languages.getByCode(args[1]) or m_languages.err(args[1], 1)
local coiner = args[2]
local coiner_text = args["alt"] or args[2]
local wikilink = args["w"] or coiner
local date = args["th"]
local result = ""
if not args["notext"] then
result = result .. "[[Lampiran:Glosarium#cetusan|" .. (args["nocap"] and "d" or "D") .. "icetuskan]] oleh "
end
local categories = {}
if not args["nocat"] then
if not args["nobycat"] then
table.insert(categories, lang:getCanonicalName() .. " dicetuskan oleh " .. coiner)
end
table.insert(categories, lang:getCanonicalName() .. " hasil cetusan")
end
local link = coiner_text
if wikilink and wikilink ~= "-" then
-- create Wikipedia link
-- default to title, or interpret as language code if a colon is present
if mw.ustring.match(wikilink, ":$") then
-- just language code and a colon?
wikilink = wikilink .. coiner
end
link = "[[w:" .. wikilink .. "|" .. coiner_text .. "]]"
end
local occupation = args["pekerjaan"] or args["pek"] or nil
local nationality = args["kebangsaan"]
if not occupation or #occupation < 1 then
occupation = args["pek"]
end
local occ_nat = ""
if nationality then
occ_nat = occ_nat .. nationality .. " "
end
if occupation and #occupation > 0 then
occ_nat = occ_nat .. mw.text.listToText(occupation) .. " "
end
result = result .. occ_nat .. link
if date then
result = result .. " pada tahun " .. date
end
categories = m_utilities.format_categories(categories, lang, args["sort"])
result = result .. categories
return result
end
return export