Module:tzm

विक्षनरी से

"इस मॉड्यूल हेतु प्रलेख Module:tzm/doc पर बनाया जा सकता है"

local export = {}

local lang = require("Module:languages").getByCode("tzm")
local rsplit = mw.text.split
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub

--From [[Module:hi]]
function export.new(frame)
	local title = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local pos = args[1] or ""
	local def = args[2] or "{{rfdef|tzm}}"
	local pos2 = args[3] or (args[4] and "" or false)
	local def2 = args[4] or "{{rfdef|tzm}}"
	local pos3 = args[5] or (args[6] and "" or false)
	local def3 = args[6] or "{{rfdef|tzm}}"
	local etym = args["e"] or "{{rfe|tzm}}"
	local head = args["head"] or false
	local pron = args["pron"] or false
	local g = args["g"] or false
    local g2 = args["g2"] or false
    local v = args["v"] or false
    local t = args["t"] or false
    local c = args["c"] or args["cat"] or false
    local ref = args["ref"] or false
    local cons = args["cons"] or false
    local pl = args["pl"] or false
    local plcons = args["plcons"] or false
    local pl2 = args["pl2"] or false
    local pl2cons = args["pl2cons"] or false
    local f = args["f"] or false

	local result = ""
	
	local function genTitle(text)
		local pos_title = {
			[""] = "Noun", ["n"] = "Noun", ["pn"] = "Proper noun", ["propn"] = "Proper noun", ["pron"] = "Pronoun",
			["v"] = "Verb", ["a"] = "Adjective", ["adj"] = "Adjective", ["adv"] = "Adverb",
			["prep"] = "Preposition", ["postp"] = "Postposition", ["post"] = "Postposition", ["con"] = "Conjunction",
			["part"] = "Particle", ["suf"] = "Suffix", ["pref"] = "Prefix",
			["prov"] = "Proverb", ["id"] = "Idiom", ["ph"] = "Phrase", ["intj"] = "Interjection", ["interj"] = "Interjection",
			["num"] = "Numeral", ["abb"] = "Abbreviation", ["conj"] = "Conjunction",
            ["adj-form"] = "Adjective", ["verb-form"] = "Verb", ["noun-form"] = "Noun",
		};
		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", ["a"] = "adjective", ["adv"] = "adverb",
			["postp"] = "postposition", ["prep"] = "preposition", ["conj"] = "conjunction", ["pron"] = "pronoun",
			["intj"] = "interjection", ["pp"] = "perfect participle",
		};
		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|tzm|" .. args[class] .. "}}"
			
			if args[class .. "2"] then
				code = code .. "\n* {{l|tzm|" .. args[class .. "2"] .. "}}"
				
				if args[class .. "3"] then
					code = code .. "\n* {{l|tzm|" .. args[class .. "3"] .. "}}"
					
					if args[class .. "4"] then
						code = code .. "\n* {{l|tzm|" .. args[class .. "4"] .. "}}"
					end
				end
			end
		end
		return code
	end
	
	-- header
	result = result .. "==Central Atlas Tamazight=="
	
	-- Wikipedia
	if args["wp"] then result = result .. "\n{{wp|lang=tzm}}" end
	
	-- Alternative forms
	result = result .. other("alt", "Alternative forms", args)
	
	-- Etymology
	result = result .. "\n\n===Etymology===\n" .. etym
	
	-- Pronunciation
	if pron then
		result = result .. "\n\n===Pronunciation===\n{{tzm-IPA" .. ((pron ~= title and pron ~= "") and ("|" .. gsub(pron, ",", "|")) or "") .. "}}"
	else
		result = result .. "\n\n===Pronunciation===\n{{tzm-IPA}}"
	end
	result = result .. "\n\n===" .. genTitle(pos) .. "===\n{{tzm-" .. genHead(pos) .. (head and ("|head=" .. head) or "") .. (g and ("|" .. g) or "") .. (t and ("|" .. t) or "") .. (cons and ("|cons=" .. cons) or "") .. (pl and ("|pl=" .. pl) or "") .. (pl2 and ("|pl2=" .. pl2) or "") .. (plcons and ("|plcons=" .. plcons) or "") .. (pl2cons and ("|pl2cons=" .. pl2cons) or "") .. (f and ("|f=" .. f) or "") .. "}}\n\n# " .. def
    
	-- Other
	result = result .. other("der", "=Derived terms=", args)
	result = result .. other("also", "=See also=", args)
	
	-- Actual Entry
	if pos2 then
		result = result .. "\n\n===" .. genTitle(pos2) .. "===\n{{tzm-" .. genHead(pos2) .. (head and ("|head=" .. head) or "") .. (g2 and ("|g=" .. g2) or "") .. (cons and ("|cons=" .. cons) or "") .. (pl and ("|pl=" .. pl) or "") .. "}}\n\n# " .. def2
	end
	
	if pos3 then
		result = result .. "\n\n===" .. genTitle(pos3) .. "===\n{{tzm-" .. genHead(pos3) .. (head and ("|head=" .. head) or "")  .. (g3 and ("|g=" .. g3) or "") .. (cons and ("|cons=" .. cons) or "") .. (pl and ("|pl=" .. pl) or "") .. "}}\n\n# " .. def3
	end

    -- categories and references
    if ref and ref ~= "" then
    	result = result .. "\n\n===References===\n* {{R:Penchoen:1973" .. (ref and ("|" .. ref) or "") .."}}"
    elseif ref == "" then
    	result = result .. "\n\n===References===\n* {{R:Penchoen:1973}}"
    end
    
    if c then
    	result = result .. "\n\n{{c|tzm" .. ((c ~= title and c ~= "") and ("|" .. gsub(c, ",", "|")) or "") .. "}}"
    end
	
	return result
end

return export