Module:qlu-nouns: Difference between revisions
Jump to navigation
Jump to search
Lëtzelúcia (talk | contribs) No edit summary |
Lëtzelúcia (talk | contribs) No edit summary |
||
| Line 143: | Line 143: | ||
table.insert(out, '<table class="inflection-table" style="border-collapse:collapse; width:40%; font-size:90%;">') | table.insert(out, '<table class="inflection-table" style="border-collapse:collapse; width:40%; font-size:90%;">') | ||
-- Header row | -- Header row (without thead) | ||
table.insert(out, " | table.insert(out, "<tr>") | ||
table.insert(out, cell("", true, "background:#444; color:#fff; padding:4px;")) | table.insert(out, cell("", true, "background:#444; color:#fff; padding:4px;")) | ||
table.insert(out, cell("singular", true, "background:#444; color:#fff; padding:4px;")) | table.insert(out, cell("singular", true, "background:#444; color:#fff; padding:4px;")) | ||
table.insert(out, cell("plural", true, "background:#444; color:#fff; padding:4px;")) | table.insert(out, cell("plural", true, "background:#444; color:#fff; padding:4px;")) | ||
table.insert(out, "</tr | table.insert(out, "</tr>") | ||
-- Body rows | -- Body rows (without tbody) | ||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
table.insert(out, "<tr>") | table.insert(out, "<tr>") | ||
table.insert(out, cell(row.label, false, "background:#ddd; padding:4px; font-weight:bold; white-space:nowrap;")) | table.insert(out, cell(row.label, false, "background:#ddd; padding:4px; font-weight:bold; white-space:nowrap;")) | ||
table.insert(out, cell(row.sg, false, "background:#fff; padding:4px; text-align:center;")) | table.insert(out, cell(row.sg, false, "background:#fff; padding:4px; text-align:center;")) | ||
table.insert(out, cell(row.pl, false, "background:#fff; padding:4px; text-align:center;")) | table.insert(out, cell(row.pl, false, "background:#fff; padding:4px; text-align:center;")) | ||
table.insert(out, "</tr>") | table.insert(out, "</tr>") | ||
end | end | ||
table.insert(out, "</table>") | table.insert(out, "</table>") | ||
if data.footnotes and data.footnotes ~= "" then | if data.footnotes and data.footnotes ~= "" then | ||
table.insert(out, '<div class="footnotes" style="font-size:80%; margin-top:0.5em;">' .. data.footnotes .. "</div>") | table.insert(out, '<div class="footnotes" style="font-size:80%; margin-top:0.5em;">' .. data.footnotes .. "</div>") | ||
| Line 172: | Line 166: | ||
return table.concat(out, "\n") | return table.concat(out, "\n") | ||
end | end | ||
return export | return export | ||
Revision as of 19:29, 29 June 2025
Documentation for this module may be created at Module:qlu-nouns/doc
local Array = require 'Module:array'
local export = {}
-- Declension paradigms for your conlang
local decls = {}
-- a-stem
decls["a"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "a"
data.forms["nom_pl"] = r .. "e"
data.forms["gen_sg"] = r .. "e"
data.forms["gen_pl"] = r .. "aro"
data.forms["dat_sg"] = r .. "a"
data.forms["dat_pl"] = r .. "evo"
data.forms["acc_sg"] = r .. "a"
data.forms["acc_pl"] = r .. "as"
end})
-- o-stem masculine
decls["o"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "u"
data.forms["nom_pl"] = r .. "i"
data.forms["gen_sg"] = r .. "i"
data.forms["gen_pl"] = r .. "oro"
data.forms["dat_sg"] = r .. "a"
data.forms["dat_pl"] = r .. "evo"
data.forms["acc_sg"] = r .. "o"
data.forms["acc_pl"] = r .. "os"
end})
-- o-stem neuter
decls["o-N"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "o"
data.forms["nom_pl"] = r .. "a"
data.forms["gen_sg"] = r .. "i"
data.forms["gen_pl"] = r .. "oro"
data.forms["dat_sg"] = r .. "a"
data.forms["dat_pl"] = r .. "evo"
data.forms["acc_sg"] = r .. "o"
data.forms["acc_pl"] = r .. "a"
end})
-- i-stem
decls["i"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "e"
data.forms["nom_pl"] = r .. "i"
data.forms["gen_sg"] = r .. "i"
data.forms["gen_pl"] = r .. "e"
data.forms["dat_sg"] = r .. "i"
data.forms["dat_pl"] = r .. "evo"
data.forms["acc_sg"] = r .. "e"
data.forms["acc_pl"] = r .. "es"
end})
-- r-stem (new)
decls["r"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "ar"
data.forms["nom_pl"] = r .. "aiu"
data.forms["gen_sg"] = r .. "eri"
data.forms["gen_pl"] = r .. "are"
data.forms["dat_sg"] = r .. "er"
data.forms["dat_pl"] = r .. "arevo"
data.forms["acc_sg"] = r .. "ar"
data.forms["acc_pl"] = r .. "aru"
end})
-- d-stem type 1 (d1)
decls["d1"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "ê"
data.forms["nom_pl"] = r .. "edi"
data.forms["gen_sg"] = r .. "edi"
data.forms["gen_pl"] = r .. "ede"
data.forms["dat_sg"] = r .. "edi"
data.forms["dat_pl"] = r .. "edevo"
data.forms["acc_sg"] = r .. "ede"
data.forms["acc_pl"] = r .. "edi"
end})
-- d-stem type 2 (d2)
decls["d2"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "â"
data.forms["nom_pl"] = r .. "adi"
data.forms["gen_sg"] = r .. "adi"
data.forms["gen_pl"] = r .. "ade"
data.forms["dat_sg"] = r .. "adi"
data.forms["dat_pl"] = r .. "adevo"
data.forms["acc_sg"] = r .. "ade"
data.forms["acc_pl"] = r .. "adi"
end})
-- u-stem masculine
decls["u"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "u"
data.forms["nom_pl"] = r .. "us"
data.forms["gen_sg"] = r .. "aus"
data.forms["gen_pl"] = r .. "eve"
data.forms["dat_sg"] = r .. "au"
data.forms["dat_pl"] = r .. "evo"
data.forms["acc_sg"] = r .. "u"
data.forms["acc_pl"] = r .. "us"
end})
-- u-stem neuter
decls["u-N"] = setmetatable({}, { __call = function(self, args, data)
local r = args[1]
data.forms["nom_sg"] = r .. "u"
data.forms["nom_pl"] = r .. "ua"
data.forms["gen_sg"] = r .. "aus"
data.forms["gen_pl"] = r .. "eve"
data.forms["dat_sg"] = r .. "au"
data.forms["dat_pl"] = r .. "evo"
data.forms["acc_sg"] = r .. "u"
data.forms["acc_pl"] = r .. "ua"
end})
-- Table generator - no external templates needed
function export.make_table(data)
local forms = data.forms
local rows = {
{ label = "[[dative case|dative]]", sg = forms["dat_sg"], pl = forms["dat_pl"] },
{ label = "[[genitive case|genitive]]", sg = forms["gen_sg"], pl = forms["gen_pl"] },
{ label = "[[accusative case|accusative]]", sg = forms["acc_sg"], pl = forms["acc_pl"] },
{ label = "[[nominative case|nominative]]", sg = forms["nom_sg"], pl = forms["nom_pl"] },
}
local function cell(content, isHeader, extraStyle)
local tag = isHeader and "th" or "td"
local style = extraStyle or ""
return string.format('<%s style="%s">%s</%s>', tag, style, content or "—", tag)
end
local out = {}
table.insert(out, '<table class="inflection-table" style="border-collapse:collapse; width:40%; font-size:90%;">')
-- Header row (without thead)
table.insert(out, "<tr>")
table.insert(out, cell("", true, "background:#444; color:#fff; padding:4px;"))
table.insert(out, cell("singular", true, "background:#444; color:#fff; padding:4px;"))
table.insert(out, cell("plural", true, "background:#444; color:#fff; padding:4px;"))
table.insert(out, "</tr>")
-- Body rows (without tbody)
for _, row in ipairs(rows) do
table.insert(out, "<tr>")
table.insert(out, cell(row.label, false, "background:#ddd; padding:4px; font-weight:bold; white-space:nowrap;"))
table.insert(out, cell(row.sg, false, "background:#fff; padding:4px; text-align:center;"))
table.insert(out, cell(row.pl, false, "background:#fff; padding:4px; text-align:center;"))
table.insert(out, "</tr>")
end
table.insert(out, "</table>")
if data.footnotes and data.footnotes ~= "" then
table.insert(out, '<div class="footnotes" style="font-size:80%; margin-top:0.5em;">' .. data.footnotes .. "</div>")
end
return table.concat(out, "\n")
end
return export