Module:Sandbox/Erutuon/Glossing abbreviations

This is an old revision of this page, as edited by Erutuon (talk | contribs) at 01:46, 15 October 2016 (fixed). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

local data = {
	["1s"] = "first person singular",
	["2s"] = "second person singular",
	["3s"] = "third person plural",
	["1p"] = "first person plural",
	["2p"] = "second person plural",
	["3p"] = "third person plural",
}

function p.abbr(frame)
	local args = frame:getParent().args[1] and frame:getParent().args or frame.args
	local abbreviation = args[1] or error("Provide an abbreviation in parameter 1")
	local expanded = data[abbreviation] or error("The abbreviation "..(abbreviation or "nil").." is not recognized")
	return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>'
end

return p