Modul:za
A modult a Modul:za/doc lapon tudod dokumentálni
local export = {}
local gsub = mw.ustring.gsub
--modified from [[MOD:th]]
function export.new(frame)
local title = mw.title.getCurrentTitle().text
local args = frame:getParent().args
local pos = genPoS(args[1] or "")
local def = args[2] or "{{rfdef|lang=th}}"
local etym = args["e"] or false
local head = args["head"] or false
local saw = args["saw"] or false
local cls = args["cls"] or false
local cat = args["cat"] or false
local wp = args["wp"] or false
local result = {}
local function genPoS(text)
local pos = {
[""] = "noun", ["n"] = "noun", ["pn"] = "proper noun", ["propn"] = "proper noun", ["pron"] = "pronoun",
["v"] = "verb", ["a"] = "adjective", ["adj"] = "adjective", ["adv"] = "adverb",
["prep"] = "preposition", ["postp"] = "postposition", ["conj"] = "conjunction",
["part"] = "particle", ["pref"] = "prefix", ["suf"] = "suffix",
["prov"] = "proverb", ["id"] = "idiom", ["ph"] = "phrase", ["intj"] = "interjection", ["interj"] = "interjection",
["cl"] = "classifier", ["cls"] = "classifier", ["num"] = "numeral", ["abb"] = "abbreviation", ["deter"] = "determiner"
}
return pos_title[text] or text
end
local function other(class, title, args)
local code = ""
if args[class] then
code = code .. "\n\n===" .. title .. "===\n{{th-" .. class .. "|" ..
table.concat(mw.text.split(args[class], ","), "|")
i = 2
while args[class .. i] do
code = code .. "|" .. args[class .. i]
i = i + 1
end
code = code .. "}}"
end
return code
end
table.insert(result, "==Zhuang==")
if wp then table.insert(result, "\n{{wikipedia" .. (wp ~= "y" and "|" .. wp or "") .. "|lang=za}}") end
table.insert(result, other("alt", "Alternative forms", args))
if etym then table.insert(result, "\n\n===Etymology===\n" .. etym) end
table.insert(result, "\n\n===Pronunciation===\n* {{za-pron}}")
local pos_title = gsub(pos, "^.", mw.ustring.upper)
table.insert(result, "\n\n===" .. pos_title .. "===\n{{za-head|" .. pos ..
(head and ("|head=" .. head) or "") ..
(saw and ("|saw=" .. saw) or "") ..
((cls and pos == "noun") and "|cls=" .. cls or "") .. "}}\n\n# " .. def)
table.insert(result, other("syn", "=Synonyms=", args))
table.insert(result, other("ant", "=Antonyms=", args))
table.insert(result, other("der", "=Derived terms=", args))
table.insert(result, other("rel", "=Related terms=", args))
table.insert(result, other("also", "=See also=", args))
if cat then table.insert(result, "\n\n{{C|za|" .. cat .. "}}") end
return table.concat(result)
end
return export