-- Ported from ] authored by Ghybu
-- ]
-- ] ]
-- ] ]
local export = {}
-- FERHENG --
-- Definite (def)
-- Indefinite (indef)
-- Singular (s) / Plural (p)
-- Case
-- Nominative (nom)
-- Construct (cons)
-- Oblique (obl)
-- Demonstrative oblique (demons_obl)
-- Vocativ (voc)
local gsub = mw.ustring.gsub
local find = mw.ustring.find
-- bolden the suffix
function b(bold)
return '<b>' .. bold .. '</b>'
end
function pronounDecl(g)
if g == 'f' then return 'wê' end
if g == 'm' then return 'wî' end
end
function export.decl(title, gender, variant, bold)
local decl = {}
decl.def_nom_s = title
decl.def_nom_p = title
if (find(title, '$')) then
if (gender == 'm') then
decl.def_cons_s = gsub(title, '(.)$', '%1' .. b('ê'))
decl.def_cons_p = gsub(title, '(.)$', '%1' .. b('ên'))
decl.def_obl_s = gsub(title, '(.)$', '%1' .. b('î'))
decl.def_obl_p = gsub(title, '(.)$', '%1' .. b('an'))
decl.indef_nom_s = gsub(title, '(.)$', '%1' .. b('ek'))
decl.indef_nom_p = gsub(title, '(.)$', '%1' .. b('in'))
decl.indef_cons_s = gsub(title, '(.)$', '%1' .. b('ekî'))
decl.indef_cons_p = gsub(title, '(.)$', '%1' .. b('ine'))
decl.indef_obl_s = gsub(title, '(.)$', '%1' .. b('ekî'))
decl.indef_obl_p = gsub(title, '(.)$', '%1' .. b('inan'))
decl.voc_s = gsub(title, '(.)$', '%1' .. b('o'))
decl.voc_p = gsub(title, '(.)$', '%1' .. b('ino'))
elseif (gender == 'f') then
decl.def_cons_s = gsub(title, '(.)$', '%1' .. b('a'))
decl.def_cons_p = gsub(title, '(.)$', '%1' .. b('ên'))
decl.def_obl_s = gsub(title, '(.)$', '%1' .. b('ê'))
decl.def_obl_p = gsub(title, '(.)$', '%1' .. b('an'))
decl.indef_nom_s = gsub(title, '(.)$', '%1' .. b('ek'))
decl.indef_nom_p = gsub(title, '(.)$', '%1' .. b('in'))
decl.indef_cons_s = gsub(title, '(.)$', '%1' .. b('eke'))
decl.indef_cons_p = gsub(title, '(.)$', '%1' .. b('ine'))
decl.indef_obl_s = gsub(title, '(.)$', '%1' .. b('ekê'))
decl.indef_obl_p = gsub(title, '(.)$', '%1' .. b('inan'))
decl.voc_s = gsub(title, '(.)$', '%1' .. b('ê'))
decl.voc_p = gsub(title, '(.)$', '%1' .. b('ino'))
end
elseif (find(title, '$') and variant == '2') then
if (gender == 'm') then
decl.def_cons_s = gsub(title, '(.)$', '%1' .. b('yê'))
decl.def_cons_p = gsub(title, '(.)$', '%1' .. b('yên'))
if (find(title, '$')) then
decl.def_obl_s = title
else
decl.def_obl_s = gsub(title, '(.)$', '%1' .. b('yî'))
end
decl.def_obl_p = gsub(title, '(.)$', '%1' .. b('yan'))
decl.indef_nom_s = gsub(title, '(.)$', '%1' .. b('yek'))
decl.indef_nom_p = gsub(title, '(.)$', '%1' .. b('yin'))
decl.indef_cons_s = gsub(title, '(.)$', '%1' .. b('yekî'))
decl.indef_cons_p = gsub(title, '(.)$', '%1' .. b('yine'))
decl.indef_obl_s = gsub(title, '(.)$', '%1' .. b('yekî'))
decl.indef_obl_p = gsub(title, '(.)$', '%1' .. b('yinan'))
decl.voc_s = gsub(title, '(.)$', '%1' .. b('yo'))
decl.voc_p = gsub(title, '(.)$', '%1' .. b('yino'))
elseif (gender == 'f') then
decl.def_cons_s = gsub(title, '(.)$', '%1' .. b('ya'))
decl.def_cons_p = gsub(title, '(.)$', '%1' .. b('yên'))
if (find(title, '$')) then
decl.def_obl_s = title
else
decl.def_obl_s = gsub(title, '(.)$', '%1' .. b('yê'))
end
decl.def_obl_p = gsub(title, '(.)$', '%1' .. b('yan'))
decl.indef_nom_s = gsub(title, '(.)$', '%1' .. b('yek'))
decl.indef_nom_p = gsub(title, '(.)$', '%1' .. b('yin'))
decl.indef_cons_s = gsub(title, '(.)$', '%1' .. b('yeke'))
decl.indef_cons_p = gsub(title, '(.)$', '%1' .. b('yine'))
decl.indef_obl_s = gsub(title, '(.)$', '%1' .. b('yekê'))
decl.indef_obl_p = gsub(title, '(.)$', '%1' .. b('yinan'))
decl.voc_s = gsub(title, '(.)$', '%1' .. b('yê'))
decl.voc_p = gsub(title, '(.)$', '%1' .. b('yino'))
end
elseif (find(title, '$')) then
if (gender == 'm') then
decl.def_cons_s = gsub(title, '(.)$', '%1' .. b('yê'))
decl.def_cons_p = gsub(title, '(.)$', '%1' .. b('yên'))
if (find(title, '$')) then
decl.def_obl_s = title
else
decl.def_obl_s = gsub(title, '(.)$', '%1' .. b('yî'))
end
decl.def_obl_p = gsub(title, '(.)$', '%1' .. b('yan'))
decl.indef_nom_s = gsub(title, '(.)$', '%1' .. b('yek'))
decl.indef_nom_p = gsub(title, '(.)$', '%1' .. b('yin'))
decl.indef_cons_s = gsub(title, '(.)$', '%1' .. b('yekî'))
decl.indef_cons_p = gsub(title, '(.)$', '%1' .. b('yine'))
decl.indef_obl_s = gsub(title, '(.)$', '%1' .. b('yekî'))
decl.indef_obl_p = gsub(title, '(.)$', '%1' .. b('yinan'))
decl.voc_s = gsub(title, '(.)$', '%1' .. b('yo'))
decl.voc_p = gsub(title, '(.)$', '%1' .. b('yino'))
elseif (gender == 'f') then
decl.def_cons_s = gsub(title, '(.)$', '%1' .. b('ya'))
decl.def_cons_p = gsub(title, '(.)$', '%1' .. b('yên'))
decl.def_obl_s = gsub(title, '(.)$', '%1' .. b('yê'))
decl.def_obl_p = gsub(title, '(.)$', '%1' .. b('yan'))
decl.indef_nom_s = gsub(title, '(.)$', '%1' .. b('yek'))
decl.indef_nom_p = gsub(title, '(.)$', '%1' .. b('yin'))
decl.indef_cons_s = gsub(title, '(.)$', '%1' .. b('yeke'))
decl.indef_cons_p = gsub(title, '(.)$', '%1' .. b('yine'))
decl.indef_obl_s = gsub(title, '(.)$', '%1' .. b('yekê'))
decl.indef_obl_p = gsub(title, '(.)$', '%1' .. b('yinan'))
decl.voc_s = gsub(title, '(.)$', '%1' .. b('yê'))
decl.voc_p = gsub(title, '(.)$', '%1' .. b('yino'))
end
elseif (find(title, '$')) then
if (gender == 'm') then
decl.def_cons_s = gsub(title, '(.)$', b('ê'))
decl.def_cons_p = gsub(title, '(.)$', b('ên'))
decl.def_obl_s = gsub(title, '(.)$', b('î'))
decl.def_obl_p = gsub(title, '(.)$', b('an'))
decl.indef_nom_s = gsub(title, '(.)$', 'e' .. b('k'))
decl.indef_nom_p = gsub(title, '(.)$', b('in'))
decl.indef_cons_s = gsub(title, '(.)$', 'e' .. b('kî'))
decl.indef_cons_p = gsub(title, '(.)$', b('ine'))
decl.indef_obl_s = gsub(title, '(.)$', 'e' .. b('kî'))
decl.indef_obl_p = gsub(title, '(.)$', b('inan'))
decl.voc_s = gsub(title, '(.)$', b('o'))
decl.voc_p = gsub(title, '(.)$', b('ino'))
elseif (gender == 'f') then
decl.def_cons_s = gsub(title, '(.)$', b('a'))
decl.def_cons_p = gsub(title, '(.)$', b('ên'))
decl.def_obl_s = gsub(title, '(.)$', b('ê'))
decl.def_obl_p = gsub(title, '(.)$', b('an'))
decl.indef_nom_s = gsub(title, '(.)$', 'e' .. b('k'))
decl.indef_nom_p = gsub(title, '(.)$', b('in'))
decl.indef_cons_s = gsub(title, '(.)$', 'e' .. b('ke'))
decl.indef_cons_p = gsub(title, '(.)$', b('ine'))
decl.indef_obl_s = gsub(title, '(.)$', 'e' .. b('kê'))
decl.indef_obl_p = gsub(title, '(.)$', b('inan'))
decl.voc_s = gsub(title, '(.)$', b('ê'))
decl.voc_p = gsub(title, '(.)$', b('ino'))
end
elseif (find(title, '$')) then
if (gender == 'm') then
decl.def_cons_s = gsub(title, '(.)$', b('iyê'))
decl.def_cons_p = gsub(title, '(.)$', b('iyên'))
decl.def_obl_s = gsub(title, '(.)$', b('iyî'))
decl.def_obl_p = gsub(title, '(.)$', b('iyan'))
decl.indef_nom_s = gsub(title, '(.)$', b('iyek'))
decl.indef_nom_p = gsub(title, '(.)$', b('iyin'))
decl.indef_cons_s = gsub(title, '(.)$', b('iyekî'))
decl.indef_cons_p = gsub(title, '(.)$', b('iyine'))
decl.indef_obl_s = gsub(title, '(.)$', b('iyekî'))
decl.indef_obl_p = gsub(title, '(.)$', b('iyinan'))
decl.voc_s = gsub(title, '(.)$', b('iyo'))
decl.voc_p = gsub(title, '(.)$', b('iyino'))
elseif (gender == 'f') then
decl.def_cons_s = gsub(title, '(.)$', b('iya'))
decl.def_cons_p = gsub(title, '(.)$', b('iyên'))
if (find(title, '$')) then
decl.def_obl_s = title
else
decl.def_obl_s = gsub(title, '(.)$', b('iyê'))
end
decl.def_obl_p = gsub(title, '(.)$', b('iyan'))
decl.indef_nom_s = gsub(title, '(.)$', b('iyek'))
decl.indef_nom_p = gsub(title, '(.)$', b('iyin'))
decl.indef_cons_s = gsub(title, '(.)$', b('iyeke'))
decl.indef_cons_p = gsub(title, '(.)$', b('iyine'))
decl.indef_obl_s = gsub(title, '(.)$', b('iyekê'))
decl.indef_obl_p = gsub(title, '(.)$', b('iyinan'))
decl.voc_s = gsub(title, '(.)$', b('iyê'))
decl.voc_p = gsub(title, '(.)$', b('iyino'))
end
end
-- îy --> iy + link
for i, v in pairs(decl) do
decl = gsub(decl, 'î<b>y', '<b>iy')
if bold == 'no' then
decl = gsub(decl, '<b>', '')
decl = gsub(decl, '</b>', '')
else
local lang = require("Module:languages").getByCode("kmr")
local alt = decl
decl = gsub(decl, '<b>', '')
decl = gsub(decl, '</b>', '')
local term = decl
local form = gsub(i, '_', '|')
decl = require("Module:links").full_link(
{
lang = lang,
term = term,
alt = alt,
accel = {form = form, gender = gender, lemma = title}
})
end
end
--pronouns for Demonstrative oblique form
decl.def_demons_obl_s = '] ' .. decl.def_obl_s
decl.def_demons_obl_p = ']' .. ' ' .. decl.def_obl_p
return decl
end
local function genderTable(gender)
if (gender == 'm') then return 'masculine gender'
elseif (gender == 'f') then return 'feminine gender'
end
end
function export.declension(frame)
local args = frame:getParent().args
local gender = args
local singular = args
local variant = args
local title = args
if title then
title = title
else
title = mw.title.getCurrentTitle().subpageText
end
decl_mf = require('Module:kmr-nouns/masc and fem').mf
decl_singular = require('Module:kmr-nouns/singular').singular
if (gender == 'mf') then
return decl_mf(title, variant)
elseif (singular == 's') then
return decl_singular(title, gender, variant)
else
return
'<div class="NavFrame" style="width:65%">'
..'\n<div class="NavHead" style="">Declension of ' ..title.. '</div>'
..'\n<div class="NavContent">'
..'\n{| colspan="5" border="1" style="border-collapse:collapse; background-color:white; clear:right; width:100%; " class="inflection-table"'
..'\n|-'
..'\n! colspan="3" align="center" |Definite ' .. genderTable(gender)
..'\n|-'
..'\n! style="background-color:#FFFFE0; text-align:left;" | Case'
..'\n! colspan="1" style="background-color:#FFFFE0;" | Singular'
..'\n! colspan="1" style="background-color:#FFFFE0;" | Plural'
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Nominative'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Construct'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Oblique'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Demonstrative oblique'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Vocative'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n! colspan="5" align="center" |Indefinite ' .. genderTable(gender)
..'\n|-'
..'\n!style="background-color:#FFFFE0; text-align:left;" | Case'
..'\n!colspan="1" style="background-color:#FFFFE0;" | Singular'
..'\n!colspan="1" style="background-color:#FFFFE0;" | Plural'
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Nominative'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Construct'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|-'
..'\n| style="background-color:#e7e8ea; text-align:left;" | Oblique'
..'\n|' .. export.decl(title, gender, variant)
..'\n|' .. export.decl(title, gender, variant)
..'\n|}</div></div>'
end
end
return export