Module:headword/templates

கட்டற்ற பன்மொழி அகரமுதலியான விக்சனரியில் இருந்து.

Documentation for this module may be created at Module:headword/templates/doc

local export = {}

--[[ used in Tamil language
-- Part of speech types that should not be pluralized.
local invariable = {
	["cmavo"] = true,
	["cmene"] = true,
	["fu'ivla"] = true,
	["gismu"] = true,
	["holdon"] = true, --Han tu
	["hanzi"] = true, --hanzi
	["hanja"] = true, --hanja
	["jyutping"] = true, --jyutping
	["kanji"] = true, --kanji
	["lujvo"] = true,
	["phrasebook"] = true,
	["pinyin"] = true, --pinyin
	["rafsi"] = true,
	["romaji"] = true, --romaji
}
--]]


function export.head_t(frame)
	local params = {
		[1] = {required = true, default = "und"},
		["sc"] = {},
		["cat sc"] = {},
		["sort"] = {},
		
		[2] = {required = true, default = "பெயர்ச்சொல்"},
		["cat2"] = {},
		["cat3"] = {},
		["cat4"] = {},
		
		["head"] = {list = true, allow_holes = true, default = ""},
		["tr"] = {list = true, allow_holes = true},
		["g"] = {list = true},
		
		[3] = {list = true, allow_holes = true},
		
		["f=accel"]   = {list = true, allow_holes = true},
		["f=request"] = {list = true, allow_holes = true},
		["f=alt"]     = {list = true, allow_holes = true},
		["f=sc"]      = {list = true, allow_holes = true},
		["f=id"]      = {list = true, allow_holes = true},
		["f=tr"]      = {list = true, allow_holes = true},
		["f=g"]       = {list = true, allow_holes = true},
		["f=qual"]    = {list = true, allow_holes = true},
		["f=nolink"]  = {list = true, allow_holes = true, type = "boolean"},
		["f=lang"]    = {list = true, allow_holes = true},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	-- Get language and script information
	local data = {}
	data.lang = require("Module:languages").getByCode(args[1]) or require("Module:languages").err(args[1], 1)
	data.sort_key = args["sort"]
	data.heads = args["head"]
	data.translits = args["tr"]
	data.genders = args["g"]
	
	-- Script
	local cat_sc
	
	if args["cat sc"] then
		data.sc = (args["cat sc"] and (require("Module:scripts").getByCode(args["cat sc"]) or error("The script code \"" .. args["cat sc"] .. "\" is not valid.")) or nil)
		cat_sc = cat_sc
	else
		data.sc = (args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. args["sc"] .. "\" is not valid.")) or nil)
	end
	
	-- Part-of-speech category
	data.pos_category = args[2]
	
	--[[used in Mon language
	if not data.pos_category:find("s$") and not invariable[data.pos_category] then
		-- Make the plural form of the part of speech
		if data.pos_category:find("x$") then
			data.pos_category = data.pos_category .. "es"
		else
			data.pos_category = data.pos_category .. "s"
		end
	end
	--]]
	
	if cat_sc then
		data.pos_category = data.pos_category .. "இல்" .. cat_sc:getCategoryName()
	end
	
	-- Additional categories
	data.categories = {}
	
	if args["cat2"] then
		--table.insert(data.categories, args["cat2"] .. data.lang:getCategoryName())
		if args["cat2"]:match("^சொல்லகராதி") then
			table.insert(data.categories, "உள்ளது" .. data.lang:getCategoryName() .. mw.ustring.sub(args["cat2"], 6))
		else
			table.insert(data.categories, args["cat2"] .. data.lang:getCategoryName())
		end
	end
	
	if args["cat3"] then
		--table.insert(data.categories, args["cat3"] .. data.lang:getCategoryName())
		if args["cat3"]:match("^சொல்லகராதி") then
			table.insert(data.categories, "உள்ளது" .. data.lang:getCategoryName() .. mw.ustring.sub(args["cat3"], 6))
		else
			table.insert(data.categories, args["cat3"] .. data.lang:getCategoryName())
		end
	end
	
	if args["cat4"] then
		--table.insert(data.categories, args["cat4"] .. data.lang:getCategoryName())
		if args["cat4"]:match("^சொல்லகராதி") then
			table.insert(data.categories, "உள்ளது" .. data.lang:getCategoryName() .. mw.ustring.sub(args["cat4"], 6))
		else
			table.insert(data.categories, args["cat4"] .. data.lang:getCategoryName())
		end
	end
	
	-- Inflected forms
	data.inflections = {}
	
	for i = 1, math.ceil(args[3].maxindex / 2) do
		local infl_part = {
			label    = args[3][i * 2 - 1],
			accel    = args["faccel"][i],
			request  = args["frequest"][i],
			}
		
		local form = {
			term       =  args[3][i * 2],
			alt        =  args["falt"][i],
			genders    = {args["fg"][i]},
			id         =  args["fid"][i],
			lang       =  args["flang"][i],
			nolink     =  args["fnolink"][i],
			qualifiers = {args["fqual"][i]},
			sc         =  args["fsc"][i],
			translit   =  args["ftr"][i],
			}
		
		if form.lang then
			form.lang = require("Module:languages").getByCode(form.lang) or require("Module:languages").err(form.lang, "f" .. i .. "lang")
		end
		
		if form.sc then
			form.sc = require("Module:scripts").getByCode(form.sc) or error("The script code \"" .. form.sc .. "\" is not valid.")
		end
		
		-- If no term or alt is given, then the label is shown alone.
		if form.term or form.alt then
			table.insert(infl_part, form)
		end
		
		if infl_part.label == "அல்லது" then
			-- Append to the previous inflection part, if one exists
			if #infl_part > 0 and data.inflections[1] then
				table.insert(data.inflections[#data.inflections], form)
			end
		elseif infl_part.label then
			-- Add a new inflection part
			table.insert(data.inflections, infl_part)
		end
	end
	
	return require("Module:headword").full_headword(data)
end

return export
"https://ta.wiktionary.org/w/index.php?title=Module:headword/templates&oldid=1992854" இலிருந்து மீள்விக்கப்பட்டது