Module:Dict

From Annwan’s Wiki
Revision as of 16:26, 31 March 2025 by Annwan (talk | contribs)
Jump to navigation Jump to search

local exports = {}

local langdata = require('Module:Data/Langs')
local posdata = require('Module:Data/POS')

exports.head = function(frame)
	local headword = frame.args[1]
	local lang = frame.args["lang"]
	local pos = frame.args["pos"]
	local translit = frame.args["translit"]
	local sc = frame.args["sc"]
	local ipa = frame.args["ipa"]
	assert(lang)
	assert(pos)
	assert(ipa)
	ipa = frame:expandTemplate{ title = "IPA", args = "/" .. ipa .. "/" }
	if (not translit) or translit == "" then
		translit = ""
	else
		translit = " (" .. translit .. ")"
	end
	if sc and sc ~= "" then
		headword = frame:expandTemplate{ title = 'Scr', args = { sc, headword}}
	end
	return tostring(headword) .. tostring(translit) .. " " .. tostring(ipa) .. " ''" .. tostring(pos) .. ".''\n"
		.. "[[Category:" .. tostring(langdata[lang].display_name) .. " " .. tostring(posdata[pos]) .. "]]\n"
		.. "[[Category:" .. tostring(langdata[lang].display_name) .. " Lemmas]]"
end

return exports