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 or false
local pos = args or ""
local def = args or "{{rfdef|lang=mnw}}"
local pos2 = args or (args and "" or false)
local def2 = args or "{{rfdef|lang=mnw}}"
local pos3 = args or (args and "" or false)
local def3 = args or "{{rfdef|lang=mnw}}"
local etym = args or false
local head = args or false
local ref = args or false
local cat = args or false
local result = ""
local function genTitle(text)
local pos_title = {
= "Noun", = "Noun", = "Proper noun", = "Proper noun", = "Pronoun",
= "Verb", = "Verb", = "Adjective", = "Adjective", = "Adverb",
= "Preposition", = "Postposition", = "Conjunction",
= "Particle", = "Suffix",
= "Proverb", = "Idiom", = "Phrase", = "Interjection", = "Interjection",
= "Classifier", = "Classifier", = "Numeral", = "Abbreviation", = "Determiner"
};
return pos_title or mw.ustring.upper(sub(text, 1, 1)) .. sub(text, 2, -1)
end
local function genHead(text)
local pos_head = {
= "noun", = "noun", = "proper noun", = "proper noun", = "verb", = "verb form", = "adj",
= "post", = "con", = "particle", = "pronoun",
= "proverb", = "idiom", = "phrase", = "interj",
= "abbr", = "classifier", = "det"
};
return pos_head or text
end
local function other(class, title, args)
local code = ""
if args then
code = code .. "\n\n===" .. title .. "===\n* {{l|mnw|" .. args .. "}}"
if args then
code = code .. "\n* {{l|mnw|" .. args .. "}}"
if args then
code = code .. "\n* {{l|mnw|" .. args .. "}}"
if args then
code = code .. "\n* {{l|mnw|" .. args .. "}}"
end
end
end
end
return code
end
result = result .. "==Mon=="
if args then result = result .. "\n{{wikipedia|lang=mnw" ..
(args == "y" and "" or "|" .. args) .. "}}" 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* {{mnw-IPA" .. (pron and "|" .. pron or "") .. "}}"
result = result .. "\n\n===" .. genTitle(pos) .. "===\n{{mnw-" .. 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{{mnw-" .. genHead(pos2) .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def2
end
if pos3 then
result = result .. "\n\n===" .. genTitle(pos3) .. "===\n{{mnw-" .. genHead(pos3) .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def3
end
if ref then result = result .. "\n\n===Further reading===\n* {{R:mnw:MED}}" end
if cat then result = result .. "\n\n{{C|mnw|" .. cat .. "}}" end
return result
end
return export