ข้ามไปเนื้อหา

มอดูล:fo-noun

จาก วิกิพจนานุกรม พจนานุกรมเสรี

local export = {}

local m_table = require("มอดูล:fo-noun/table")

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)

	local parent_args = frame:getParent().args
	local decl_type = (frame.args["decl"] or parent_args["decl"]) or "f1"

	local m_decl = require("มอดูล:fo-noun/data-" .. decl_type:sub(1, 1))
	if not m_decl[decl_type] then
		error("Unknown declension type '" .. decl_type .. "'")
	end
	
	local data = {forms = {}, categories = {}}
	data.defective = "no"
	data.info = ""
	
	data.head = parent_args["head"] or nil

	local args = require("มอดูล:parameters").process(parent_args, m_decl[decl_type].params, true)
	
	if not args[1] then
		setmetatable(args, {__index = function(self, key)
			return "{{{" .. key .. "}}}"
		end
		})
	end
	
	-- Generate the forms
	m_decl[decl_type](args, data)
	data["decl"] = decl_type
	
	-- Make the table
	return m_table.make_table(data)
end

return export