Difference between revisions of "Module:Sandbox/Erutuon/Glossing abbreviations"
< Module:Sandbox | Erutuon
Jump to navigation
Jump to search
blackwiki>Erutuon (alternatives) |
m (11 revisions imported) |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 12: | Line 12: | ||
["part"] = "participle", | ["part"] = "participle", | ||
["imp"] = "imperative", | ["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["sbjv"] = data["sjv"] | ||
| + | data["indef"] = data["ndef"] | ||
-- non-standard | -- non-standard | ||
data["indic"] = data["ind"] | data["indic"] = data["ind"] | ||
| Line 27: | Line 37: | ||
local args = frame:getParent().args[1] and frame:getParent().args or frame.args | 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 abbreviation = args[1] or error("Provide an abbreviation in parameter 1") | ||
| + | |||
local key = string.gsub(abbreviation, "%.$", "") | local key = string.gsub(abbreviation, "%.$", "") | ||
key = string.lower(key) | key = string.lower(key) | ||
| + | |||
local expanded = data[key] or error("The abbreviation "..(abbreviation or "nil").." is not recognized") | local expanded = data[key] or error("The abbreviation "..(abbreviation or "nil").." is not recognized") | ||
| − | return '<abbr title="'..expanded..'">'..abbreviation..'</abbr>' | + | |
| + | 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 | end | ||
return p | return p | ||
Latest revision as of 09:36, 27 September 2020
This was an early module designed to format and expand glossing abbreviations. It was used by an earlier version of Template:Gloss-abbr. It has been superseded by Template:gcl (which uses Module:Interlinear).
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",
["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 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 key = string.gsub(abbreviation, "%.$", "")
key = string.lower(key)
local expanded = data[key] 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
return p