Module:Sandbox/Erutuon/Glossing abbreviations: Difference between revisions

Content deleted Content added
allow parent arguments
m Primefac moved page Module:Sandbox/Uanfala/Glossing abbreviations to Module:Sandbox/Erutuon/Glossing abbreviations without leaving a redirect: per reasonable comment on talk page
 
(8 intermediate revisions by 2 users not shown)
Line 8:
["2p"] = "second person plural",
["3p"] = "third person plural",
["ind"] = "indicative mood",
["sjv"] = "subjunctive mood",
["part"] = "participle",
["imp"] = "imperative",
["nom"] = "nominative case",
["acc"] = "accusative case",
["gen"] = "genitive case",
["dat"] = "dative case",
["def"] = "definite",
["ndef"] = "indefinite",
["sg"] = "singular number",
["du"] = "dual number",
["pl"] = "plural number",
}
 
data["sbjv"] = data["sjv"]
data["indef"] = data["ndef"]
-- non-standard
data["indic"] = data["ind"]
data["1sg"] = data["1s"]
data["2sg"] = data["2s"]
data["3sg"] = data["3s"]
data["1pl"] = data["1p"]
data["2pl"] = data["2p"]
data["3pl"] = data["3p"]
 
function p.abbr(frame)
local parentargs = frame:getParent().args[1] and frame:getParent().args or frame.args
local abbreviation = frame.args[1] or parent.args[1] error("Provide an abbreviation in parameter 1")
local expanded = data[abbreviation] or error("The abbreviation "..(abbreviation or "nil").." is not recognized")
local key = string.gsub(abbreviation, "%.$", "")
return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>'
key = string.lower(key)
local expanded = data[abbreviationkey] or error("The abbreviation "..(abbreviation or "nil").." is not recognized")
local _, count = mw.ustring.gsub(abbreviation, "%u", "")
if count > #abbreviation * 3/4 then
return '<abbr class="smallcaps" style="font-variant: small-caps; text-transform: lowercase;" title="'..expanded..'">'..abbreviation..'</abbr>'
else
return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>'
end
end