Module:qlu-nouns: Difference between revisions

No edit summary
No edit summary
 
(11 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 = "''[[nominative case|nominative]]''" },
["nominative"] = { short_form = "nom", link = "''[[w:nominative case|nominative]]''" },
["accusative"] = { short_form = "acc", link = "''[[accusative case|accusative]]''" },
["accusative"] = { short_form = "acc", link = "''[[w:accusative case|accusative]]''" },
["genitive"] = { short_form = "gen", link = "''[[genitive case|genitive]]''" },
["genitive"] = { short_form = "gen", link = "''[[w:genitive case|genitive]]''" },
["dative"] = { short_form = "dat", link = "''[[dative case|dative]]''" },
["dative"] = { short_form = "dat", link = "''[[w:dative case|dative]]''" },
}
}


Line 176: Line 176:
local key = cases[case].short_form .. "-" .. number
local key = cases[case].short_form .. "-" .. number
return data.forms[key] or "—"
return data.forms[key] or "—"
end
local function small(text)
return frame:preprocess("{{small|" .. text .. "}}")
end
end


local out = {}
local out = {}
table.insert(out, '{| class="wikitable"\n! Case !! Singular !! Plural')
table.insert(out, '{| class="wikitable" style="text-align:center;"')
table.insert(out, '|-')
table.insert(out, '! Number !! Case !! Declension')
 
-- 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"))


for case, info in pairs(cases) do
-- Plural rows
table.insert(out, string.format('|-\n| %s || %s || %s', info.link, showForm(case, "sg"), showForm(case, "pl")))
table.insert(out, '|-')
end
table.insert(out, '! rowspan=4 | Plural')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "pl"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "pl"))
 
table.insert(out, '|-')
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, '|}')