local export = {}
local m_links = require("Module:links")
local m_utils = require("Module:utilities")
local lang = require("Module:languages").getByCode("osx")
local headers = {}
headers.strong = [=[
|- style="background-color:#EFEFEF; "
|-
! style="background-color:#FBEC5D" colspan="7" | Strong declension
]=]
headers.weak = [=[
|- style="background-color:#EFEFEF; "
|-
! style="background-color:#FBEC5D" colspan="7" | Weak declension
]=]
headers.top = function(text)
return [=[<div class="NavFrame" style="float: left; width: 100%;">
<div class="NavHead" style="text-align: center">]=] .. text .. [=[</div>
<div class="NavContent">
{| style="width: 100%; line-height: 125%; background-color:#F9F9F9; text-align:center; border: 1px solid #CCCCFF;" cellpadding="3" cellspacing="1" class="inflection-table"
|- style="background-color:#EFEFEF; "
|-
]=]
end
local decl_data = {}
decl_data["st"] = {}
setmetatable(decl_data["st"], {__call = function(self, stem, data)
data.forms["nom_sg_m"] = {stem}
data.forms["nom_sg_f"] = {stem}
data.forms["nom_sg_n"] = {stem}
data.forms["nom_pl_m"] = {stem .. "e"}
data.forms["nom_pl_f"] = {stem .. "u"}
data.forms["nom_pl_n"] = {stem .. "e"}
data.forms["acc_sg_m"] = {stem .. "ana"}
data.forms["acc_sg_f"] = {stem .. "a"}
data.forms["acc_sg_n"] = {stem}
data.forms["acc_pl_m"] = {stem .. "e"}
data.forms["acc_pl_f"] = {stem .. "u"}
data.forms["acc_pl_n"] = {stem .. "e"}
data.forms["gen_sg_m"] = {stem .. "es"}
data.forms["gen_sg_f"] = {stem .. "aro"}
data.forms["gen_sg_n"] = {stem .. "es"}
data.forms["gen_pl_m"] = {stem .. "arō"}
data.forms["gen_pl_f"] = {stem .. "arō"}
data.forms["gen_pl_n"] = {stem .. "arō"}
data.forms["dat_sg_m"] = {stem .. "umu"}
data.forms["dat_sg_f"] = {stem .. "aro"}
data.forms["dat_sg_n"] = {stem .. "umu"}
data.forms["dat_pl_m"] = {stem .. "um"}
data.forms["dat_pl_f"] = {stem .. "um"}
data.forms["dat_pl_n"] = {stem .. "um"}
return data
end
})
decl_data["wk"] = {}
setmetatable(decl_data["wk"], {__call = function(self, stem, data)
data.forms["nom_sg_m"] = {stem .. "o"}
data.forms["nom_sg_f"] = {stem .. "a"}
data.forms["nom_sg_n"] = {stem .. "a"}
data.forms["nom_pl_m"] = {stem .. "u"}
data.forms["nom_pl_f"] = {stem .. "u"}
data.forms["nom_pl_n"] = {stem .. "u"}
data.forms["acc_sg_m"] = {stem .. "un"}
data.forms["acc_sg_f"] = {stem .. "un"}
data.forms["acc_sg_n"] = {stem .. "a"}
data.forms["acc_pl_m"] = {stem .. "un"}
data.forms["acc_pl_f"] = {stem .. "un"}
data.forms["acc_pl_n"] = {stem .. "un"}
data.forms["gen_sg_m"] = {stem .. "un"}
data.forms["gen_sg_f"] = {stem .. "un"}
data.forms["gen_sg_n"] = {stem .. "un"}
data.forms["gen_pl_m"] = {stem .. "onō"}
data.forms["gen_pl_f"] = {stem .. "onō"}
data.forms["gen_pl_n"] = {stem .. "onō"}
data.forms["dat_sg_m"] = {stem .. "un"}
data.forms["dat_sg_f"] = {stem .. "un"}
data.forms["dat_sg_n"] = {stem .. "un"}
data.forms["dat_pl_m"] = {stem .. "um"}
data.forms["dat_pl_f"] = {stem .. "um"}
data.forms["dat_pl_n"] = {stem .. "um"}
return data
end
})
function insert_all(tb, args)
for _, v in ipairs(args) do
table.insert(tb, v)
end
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local parent_args = frame:getParent().args
local data = {forms = {}, categories = {}}
data.head = parent_args["head"] or nil
-- Override for templates
if not parent_args[1] then
setmetatable(parent_args, {__index = function(self, key)
return "{{{" .. key .. "}}}"
end
})
end
local wikicode = {}
if parent_args.decl == "st" then
-- do nothing yet
else
if parent_args[1] ~= "" then
insert_all(wikicode, {headers.top("Positive forms of " .. parent_args[1]), headers.strong,
make_base_table(decl_data.st(parent_args[1], data)), headers.weak, make_base_table(decl_data.wk(parent_args[1], data)),
'|}</div></div><br clear="all" />'})
end
if parent_args[2] and parent_args[2] ~= "" then
insert_all(wikicode, {headers.top("Comparative forms of " .. parent_args[1] .. " (weak only)"), headers.weak,
make_base_table(decl_data.wk(parent_args[2], data)), '|}</div></div><br clear="all" />'})
end
if parent_args[3] and parent_args[3] ~= "" then
insert_all(wikicode, {headers.top("Superlative forms of " .. parent_args[1]), headers.strong,
make_base_table(decl_data.st(parent_args[3], data)), headers.weak, make_base_table(decl_data.wk(parent_args[3], data)),
'|}</div></div><br clear="all" />'})
end
end
-- Make the table
return table.concat(wikicode)
end
local function show_form(form)
if not form then
return "—"
end
local ret = {}
for key, subform in ipairs(form) do
if mw.title.getCurrentTitle().nsText == "Reconstruction" and subform ~= "—" then
subform = "*" .. subform
end
table.insert(ret, m_links.full_link({lang = lang, term = subform}))
end
return table.concat(ret, ", ")
end
function make_base_table(data)
local function repl(param)
if param == "decl_type" then
return data.decl_type
else
return show_form(data.forms[param])
end
end
local wikicode = [=[
|-
! gender
! style="width: 33%; background-color:#FDD5B1" colspan="2" | masculine
! style="width: 33%; background-color:#FDD5B1" colspan="2" | neuter
! style="width: 33%; background-color:#FDD5B1" colspan="2" | feminine
|-
! case
! style="width: 16%; background-color:#FFEFD5" | singular
! style="width: 16%; background-color:#FFEFD5" | plural
! style="width: 16%; background-color:#FFEFD5" | singular
! style="width: 16%; background-color:#FFEFD5" | plural
! style="width: 16%; background-color:#FFEFD5" | singular
! style="width: 16%; background-color:#FFEFD5" | plural
|-
! style="background: #FFEFD5; text-align: left; font-size: 90%;"| nominative
| bgcolor="#ffffff"| {{{nom_sg_m}}}
| bgcolor="#ffffff"| {{{nom_pl_m}}}
| bgcolor="#ffffff"| {{{nom_sg_f}}}
| bgcolor="#ffffff"| {{{nom_pl_f}}}
| bgcolor="#ffffff"| {{{nom_sg_n}}}
| bgcolor="#ffffff"| {{{nom_pl_n}}}
|-
! style="background: #FFEFD5; text-align: left; font-size: 90%;"| accusative
| bgcolor="#ffffff"| {{{acc_sg_m}}}
| bgcolor="#ffffff"| {{{acc_pl_m}}}
| bgcolor="#ffffff"| {{{acc_sg_f}}}
| bgcolor="#ffffff"| {{{acc_pl_f}}}
| bgcolor="#ffffff"| {{{acc_sg_n}}}
| bgcolor="#ffffff"| {{{acc_pl_n}}}
|-
! style="background: #FFEFD5; text-align: left; font-size: 90%;"| genitive
| bgcolor="#ffffff"| {{{gen_sg_m}}}
| bgcolor="#ffffff"| {{{gen_pl_m}}}
| bgcolor="#ffffff"| {{{gen_sg_f}}}
| bgcolor="#ffffff"| {{{gen_pl_f}}}
| bgcolor="#ffffff"| {{{gen_sg_n}}}
| bgcolor="#ffffff"| {{{gen_pl_n}}}
|-
! style="background: #FFEFD5; text-align: left; font-size: 90%;"| dative
| bgcolor="#ffffff"| {{{dat_sg_m}}}
| bgcolor="#ffffff"| {{{dat_pl_m}}}
| bgcolor="#ffffff"| {{{dat_sg_f}}}
| bgcolor="#ffffff"| {{{dat_pl_f}}}
| bgcolor="#ffffff"| {{{dat_sg_n}}}
| bgcolor="#ffffff"| {{{dat_pl_n}}}
]=]
local ret = mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)
return ret
end
return export