local lang = require("Module:languages").getByCode("fy")
local export = {}
function export.adjective(frame)
local params = {
= {},
= {},
= {},
= {},
= {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local make_auto_subtabler = require("Module:auto-subtable")
local data = {forms = make_auto_subtabler(), categories = {}, comparable = true}
-- Get parameters
local pred = args
local infl = args
local part = args
if args == "-" then
data.comparable = false
end
local base = mw.title.getCurrentTitle().nsText == "Template" and "-" or mw.title.getCurrentTitle().text
-- Positive degree
if pred == "-" then
pred = nil
elseif not pred then
pred = base
end
if not infl then
infl = base .. "e"
end
if part == "-" then
part = nil
elseif not part then
if base:find("s$") then
part = base
else
part = base .. "s"
end
end
data.forms = {pred}
data.forms = {infl}
data.forms = {base}
data.forms = {infl}
data.forms = {infl}
data.forms = {part}
if data.comparable then
-- Comparative degree
local comd_base = {args}
if not comd_base then
-- Adjectives ending in -r get an extra -d- in the comparative,
-- disregarding the inflected form.
if base:find("r$") then
comd_base = {base .. "der"}
-- Adjectives ending in -l or -n also get an extra -d-,
-- but it's optional alongside the form without it.
elseif base:find("$") then
comd_base = {base .. "der", infl .. "r"}
else
comd_base = {infl .. "r"}
end
end
for _, form in ipairs(comd_base) do
table.insert(data.forms, form)
table.insert(data.forms, form)
table.insert(data.forms, form .. "e")
table.insert(data.forms, form .. "e")
table.insert(data.forms, form .. "e")
table.insert(data.forms, form .. "s")
end
-- Superlative degree
local supd_base = {args}
if not supd_base then
if base:find("st$") then
supd_base = {base}
else
supd_base = {part .. "t"}
end
end
for _, form in ipairs(supd_base) do
table.insert(data.forms, "it ]")
table.insert(data.forms, "it ]")
table.insert(data.forms, form .. "e")
table.insert(data.forms, form .. "e")
table.insert(data.forms, form .. "e")
table.insert(data.forms, form .. "e")
end
end
-- Remove metatable.
data.forms:un_auto_subtable()
return make_table(data)
end
-- Make the table
function make_table(data)
local function repl(param)
local accel = true
local no_store = false
if param == "lemma" then
return require("Module:links").full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
elseif param == "info" then
return data.title and " (" .. data.title .. ")" or ""
elseif string.sub(param, 1, 1) == "!" then
no_store = true
param = string.sub(param, 2)
elseif string.sub(param, 1, 1) == "#" then
accel = false
param = string.sub(param, 2)
end
local forms = data.forms
if not forms then
return "—"
end
local ret = {}
for key, subform in ipairs(forms) do
table.insert(ret, require("Module:links").full_link({lang = lang, term = subform, accel = accel and {form = param, lemma = data.lemma, no_store = no_store} or nil}))
end
return table.concat(ret, "<br/>")
end
local wikicode = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="border: 1px solid #CCCCFF;" cellspacing="1" cellpadding="3"
|- style="background: #CCCCFF;"
! colspan="5" class="vsToggleElement" style="text-align: left" | Inflection of {{{lemma}}}{{{info}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | uninflected
| style="min-width: 12em;" | {{{!indef|n|s}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | inflected
| {{{!indef|c|s}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | comparative
| {{{!indef|n|s|comd}}}
|- class="vsHide" style="background: #CCCCFF;"
| colspan="2" style="background: #E6E6FF;" |
! style="min-width: 12em;" | ]]=] .. (data.comparable and [=[
! style="min-width: 12em;" | ]
! style="min-width: 12em;" | ]]=] or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" colspan="2" | ]/]
| {{{pred}}}]=] .. (data.comparable and " || {{{pred|comd}}} || {{{pred|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" rowspan="3" | ]
! style="background: #CCCCFF;" | ] ]
| {{{indef|c|s}}}]=] .. (data.comparable and " || {{{indef|c|s|comd}}} || {{{indef|c|s|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | ] ]
| {{{indef|n|s}}}]=] .. (data.comparable and " || {{{indef|n|s|comd}}} || {{{indef|n|s|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background:#CCCCFF;" | ]
| {{{indef|p}}}]=] .. (data.comparable and " || {{{indef|p|comd}}} || {{{indef|p|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" colspan="2" | ]
| {{{def}}}]=] .. (data.comparable and " || {{{def|comd}}} || {{{def|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" colspan="2" | ]
| {{{par}}}]=] .. (data.comparable and " || {{{par|comd}}} || {{{par|supd}}}" or "") .. [=[
|}]=]
return mw.ustring.gsub(wikicode, "{{{(?+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end
return export