Modul:sh-headword

Daripada Wiktionary

Pendokumenan untuk modul ini boleh diciptakan di Modul:sh-headword/doc

local export = {}

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


local function otherscript(inflections, args)
	local title = mw.title.getCurrentTitle()
	local sc = require("Module:scripts").findBestScript(title.subpageText, lang)
	
	local other_sc
	
	if sc:getCode() == "Latn" then
		other_sc = "Cyrl"
	elseif sc:getCode() == "Cyrl" then
		other_sc = "Latn"
	end
	
	other_sc = require("Module:scripts").getByCode(other_sc)
	local inflection = {label = "Ejaan " .. other_sc:getCanonicalName()}
	
	for i, head in ipairs(args["head"]) do
		if head == "" then
			head = title.subpageText
		end
		
		local tr = args["tr"][i]
		
		if not tr then
			tr = require("Module:sh-translit").tr(require("Module:links").remove_links(head), "sh", sc:getCode())
		end
		
		table.insert(inflection, {term = tr, sc = other_sc})
	end
	
	table.insert(inflections, inflection)
end


function export.basic(frame)
	local params = {
		["head"] = {list = true, default = ""},
		["tr"] = {list = true, allow_holes = true},
		}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local data = {lang = lang, pos_category = frame.args[1], categories = {}, heads = args["head"], genders = {}, inflections = {}}
	
	otherscript(data.inflections, args)
	
	return require("Module:headword").full_headword(data)
end