Modul:my
A modult a Modul:my/doc lapon tudod dokumentálni
local export = {}
local gsub = mw.ustring.gsub
function export.new(frame)
local title = mw.title.getCurrentTitle().text
local args = frame:getParent().args
local pron = args["p"] or false
local pos = args[1] or ""
local def = args[2] or "{{rfdef|lang=my}}"
local pos2 = args[3] or (args[4] and "" or false)
local def2 = args[4] or "{{rfdef|lang=my}}"
local pos3 = args[5] or (args[6] and "" or false)
local def3 = args[6] or "{{rfdef|lang=my}}"
local etym = args["e"] or false
local head = args["head"] or false
local ref = args["ref"] or false
local cat = args["cat"] or false
local result = ""
local function genTitle(text)
local pos_title = {
[""] = "Noun", ["n"] = "Noun", ["pn"] = "Proper noun", ["propn"] = "Proper noun", ["pron"] = "Pronoun",
["v"] = "Verb", ["vf"] = "Verb", ["a"] = "Adjective", ["adj"] = "Adjective", ["adv"] = "Adverb",
["prep"] = "Preposition", ["postp"] = "Postposition", ["conj"] = "Conjunction",
["part"] = "Particle", ["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 mw.ustring.upper(sub(text, 1, 1)) .. sub(text, 2, -1)
end
local function genHead(text)
local pos_head = {
[""] = "noun", ["n"] = "noun", ["pn"] = "proper noun", ["propn"] = "proper noun", ["v"] = "verb", ["vf"] = "verb form", ["a"] = "adj",
["postp"] = "post", ["conj"] = "con", ["part"] = "particle", ["pron"] = "pronoun",
["prov"] = "proverb", ["id"] = "idiom", ["ph"] = "phrase", ["intj"] = "interj",
["abb"] = "abbr", ["cl"] = "classifier", ["deter"] = "det"
};
return pos_head[text] or text
end
local function other(class, title, args)
local code = ""
if args[class] then
code = code .. "\n\n===" .. title .. "===\n* {{l|my|" .. args[class] .. "}}"
if args[class .. "2"] then
code = code .. "\n* {{l|my|" .. args[class .. "2"] .. "}}"
if args[class .. "3"] then
code = code .. "\n* {{l|my|" .. args[class .. "3"] .. "}}"
if args[class .. "4"] then
code = code .. "\n* {{l|my|" .. args[class .. "4"] .. "}}"
end
end
end
end
return code
end
result = result .. "==Burmese=="
if args["wp"] then result = result .. "\n{{wikipedia|lang=my" ..
(args["wp"] == "y" and "" or "|" .. args["wp"]) .. "}}" end
result = result .. other("alt", "Alternative forms", args)
if etym then result = result .. "\n\n===Etymology===\n" .. etym end
result = result .. "\n\n===Pronunciation===\n* {{my-IPA" .. (pron and "|" .. pron or "") .. "}}"
result = result .. "\n\n===" .. genTitle(pos) .. "===\n{{my-" .. genHead(pos) .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def
result = result .. other("syn", "=Synonyms=", args)
result = result .. other("ant", "=Antonyms=", args)
result = result .. other("der", "=Derived terms=", args)
result = result .. other("also", "=See also=", args)
if pos2 then
result = result .. "\n\n===" .. genTitle(pos2) .. "===\n{{my-" .. genHead(pos2) .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def2
end
if pos3 then
result = result .. "\n\n===" .. genTitle(pos3) .. "===\n{{my-" .. genHead(pos3) .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def3
end
if ref then result = result .. "\n\n===Further reading===\n* {{R:my:MED}}" end
if cat then result = result .. "\n\n{{C|my|" .. cat .. "}}" end
return result
end
return export