local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local export = {}
local lang = require("Module:languages").getByCode("da")
local function postprocess(args, data)
-- Check if the lemma form matches the page name
if (lang:makeEntryName(data.forms)) ~= mw.title.getCurrentTitle().text then
table.insert(data.categories, lang:getCanonicalName() .. " entries with inflection not matching pagename")
end
end
--[=[
Inflection functions
]=]--
function export.reg(frame)
local params = {
= {},
= {}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {forms = {}, info = nil, categories = {}}
local base = mw.title.getCurrentTitle().subpageText
local t = base .. "t"
local e = (args or base) .. "e"
local comp
local sup
local supe
if mw.ustring.find(base, "$") or mw.ustring.find(base, "sk$") then
t = base
end
if mw.ustring.find(base, "e$") then
e = base
end
if args == "peri" then
comp = "] ]"
sup = "] ]"
supe = "] ]"
elseif args == "st" then
comp = (args or base) .. "ere"
sup = base .. "st"
supe = base .. "ste"
elseif args == "est" then
comp = (args or base) .. "ere"
sup = (args or base) .. "est"
supe = (args or base) .. "este"
end
data.forms = {base}
data.forms = {t}
data.forms = {e}
data.forms = {e}
data.forms = {comp}
data.forms = {comp}
data.forms = {comp}
data.forms = {comp}
data.forms = {sup}
data.forms = {sup}
data.forms = {sup}
data.forms = {supe}
postprocess(args, data)
return make_table(data)
end
-- Make the table
function make_table(data)
local function repl(param)
if param == "info" then
return data.info and " (" .. mw.getContentLanguage():ucfirst(data.info or "") .. ")" or ""
elseif param == "lemma" then
return m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
end
local form = data.forms
if not form or #form == 0 then
return "—"
end
local ret = {}
for key, subform in ipairs(form) do
table.insert(ret, m_links.full_link({lang = lang, term = subform}))
end
return table.concat(ret, ", ")
end
local wikicode = mw.getCurrentFrame():expandTemplate{
title = 'inflection-table-top',
args = {
title = 'Inflection of {{{lemma}}}{{{info}}}',
palette = 'red', -- Danish flag colour?
tall = 'yes' -- collapsible
}
}
wikicode = wikicode .. [=[
!
! positive
! comparative
! superlative
|-
! indefinite common singular
| {{{pos_indf_c_sg}}}
| {{{comp_indf_c_sg}}}
| {{{sup_indf_c_sg}}}<sup>2</sup>
|-
! indefinite neuter singular
| {{{pos_indf_n_sg}}}
| {{{comp_indf_n_sg}}}
| {{{sup_indf_n_sg}}}<sup>2</sup>
|-
! plural
| {{{pos_indf_pl}}}
| {{{comp_indf_pl}}}
| {{{sup_indf_pl}}}<sup>2</sup>
|-
! definite attributive<sup>1</sup>
| {{{pos_defn}}}
| {{{comp_defn}}}
| {{{sup_defn}}}
]=]
wikicode = wikicode .. mw.getCurrentFrame():expandTemplate{
title = 'inflection-table-bottom',
args = {
notes = '<sup>1</sup> When an adjective is applied predicatively to something definite,<br>the corresponding "indefinite" form is used.<br>' ..
'<sup>2</sup> The "indefinite" superlatives may not be used attributively.'
}
}
return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl) .. m_utilities.format_categories(data.categories, lang)
end
return export