Bước tới nội dung

Mô đun:bug-headword

Từ điển mở Wiktionary
local export = {}

local lang = require("Module:languages").getByCode("bug")

local insert = table.insert

local pos_functions = {}

-- The main entry point.
function export.show(frame)
	local poscat = frame.args[1] or error(
	   "Part of speech has not been specified. Please pass parameter 1 to the module invocation.")

	local parent_args = frame:getParent().args
	local params = {
		head = {list = true, disallow_holes = true},
		tr = {list = true, allow_holes = true},
		pagename = true,
	}

	local args = require("Module:parameters").process(parent_args, params)

	-- Gather parameters
	local data = {
		lang = lang,
		pos_category = poscat,
		categories = {},
		heads = args.head,
		translits = args.tr,
		inflections = {},
	}

	local pagename = args.pagename or mw.loadData("Module:headword/data").pagename
	local sc = lang:findBestScript(pagename)

	if sc:getCode() == "Latn" then
		local inflection = {label = "chính tả Lontara"}

		local other = require("Module:bug-translit").tr(pagename, "bug", sc:getCode())
		insert(inflection, {term = other})
		insert(data.inflections, inflection)
	end

	if pos_functions[poscat] then pos_functions[poscat].func(args, data) end

	return require("Module:headword").full_headword(data)
end

return export