มอดูล:mfa-headword

จาก วิกิพจนานุกรม พจนานุกรมเสรี
local export = {}
local pos_functions = {}

local u = mw.ustring.char
local lang = require("Module:languages").getByCode("mfa")
local PAGENAME = mw.title.getCurrentTitle().text
local script = lang:findBestScript(PAGENAME) -- ms-Arab or Thai

function export.show(frame)

	local args = frame:getParent().args
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	-- หมวดหมู่เป็นภาษาไทย
	local poscat_th = require("Module:utilities").translate_term(poscat)
	
	local data = {lang = lang, sc = script, pos_category = poscat_th, categories = {poscat_th .. "ภาษามลายูแบบปัตตานีใน" .. script:getCategoryName()}, heads = {args["head"]}, translits = {"-"}, inflections = {}}
	
	if mw.ustring.find(PAGENAME, "ฆ") then
		table.insert(data.categories, "ศัพท์ภาษามลายูแบบปัตตานีที่สะกดอักษรไทยผิด")
		error("Please use กฺ /ɡ/ or รฺ /ɣ/ in place of ฆ.")
	end

	if mw.ustring.find(PAGENAME, "[كڬ]") then
		table.insert(data.categories, "ศัพท์ภาษามลายูแบบปัตตานีที่สะกดอักษรยาวีผิด")
		error("Please use ک in place of ك and ݢ in place of ڬ.")
	end

	local special_marks = "["..u(0x200B).."-"..u(0x200F).."]" -- ZWSP, ZWNJ, ZWJ, LRM, RLM
	if mw.ustring.find(PAGENAME, special_marks) then
		table.insert(data.categories, "ศัพท์ภาษามลายูแบบปัตตานีที่สะกดอักษรยาวีผิด")
		error("Please remove ZWSP, ZWNJ, ZWJ, LRM, and RLM from title/headword.")
	end
	
	local thai = {label = "อักษรไทย"}
	local sc_Thai = require("Module:scripts").getByCode("Thai")
	if args["th"] then table.insert(thai, { term = args["th"], sc = sc_Thai }) end
	if #thai > 0 then table.insert(data.inflections, thai) end
	
	if pos_functions[poscat_th] then
		pos_functions[poscat_th](args, data)
	end

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

end

return export