Module:qlu-nouns: Difference between revisions

No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 153: Line 153:
-- Display metadata
-- Display metadata
local cases = {
local cases = {
["nominative"] = { short_form = "nom", link = "''[[w:nominative case|nom]]''" },
["nominative"] = { short_form = "nom", link = "''[[w:nominative case|nominative]]''" },
["accusative"] = { short_form = "acc", link = "''[[w:accusative case|acc]]''" },
["accusative"] = { short_form = "acc", link = "''[[w:accusative case|accusative]]''" },
["genitive"] = { short_form = "gen", link = "''[[w:genitive case|gen]]''" },
["genitive"] = { short_form = "gen", link = "''[[w:genitive case|genitive]]''" },
["dative"] = { short_form = "dat", link = "''[[w:dative case|dat]]''" },
["dative"] = { short_form = "dat", link = "''[[w:dative case|dative]]''" },
}
}


Line 178: Line 178:
end
end


local case_order = {"dative", "genitive", "accusative", "nominative"}
local function small(text)
return frame:preprocess("{{small|" .. text .. "}}")
end


local out = {}
local out = {}
-- Table start with styled header row: dark gray background, white text
table.insert(out, '{| class="wikitable" style="text-align:center;"')
table.insert(out, '{| class="wikitable" style="border-collapse:collapse; width: 40%;"')
table.insert(out, '|-')
table.insert(out, '! style="background:#444; color:white; padding:4px;" | Case')
table.insert(out, '! Number !! Case !! Declension')
table.insert(out, '! style="background:#444; color:white; padding:4px;" | Singular')
 
table.insert(out, '! style="background:#444; color:white; padding:4px;" | Plural')
-- Singular rows
table.insert(out, '|-')
table.insert(out, '! rowspan=4 | Singular')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "sg"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "sg"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "sg"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "sg"))
 
-- Plural rows
table.insert(out, '|-')
table.insert(out, '! rowspan=4 | Plural')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "pl"))


for _, case in ipairs(case_order) do
table.insert(out, '|-')
local case_name = cases[case].link:gsub("''", "") -- Remove italics to style ourselves
table.insert(out, '! ' .. small("acc."))
-- Case name column with light gray background, forms with white background
table.insert(out, '| ' .. showForm("accusative", "pl"))
table.insert(out, string.format('|-\n| style="background:#ddd; padding:4px;" | %s || style="background:#fff; padding:4px;" | %s || style="background:#fff; padding:4px;" | %s',
 
case_name, showForm(case, "sg"), showForm(case, "pl")))
table.insert(out, '|-')
end
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "pl"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "pl"))


table.insert(out, '|}')
table.insert(out, '|}')
return table.concat(out, '\n')
return table.concat(out, '\n')
end
end


return export
return export