Modul:PadežKonverter

Dokumentaciju za ovaj modul možete napraviti na stranici Modul:PadežKonverter/dok

--[[
---- ** PadežKonverter ** ----

]]
local str = {}
 
local kons = 'bcčćdDŽđfghjklLJmnNJprsštvzž'
local vok  = 'aeiou'

--[[
Genitiv
Korištenje:
{{#invoke:PadežKonverter|gen|TEKST|}}
]]
function str.gen(frame)
    local word = frame.args[1]
    local lastl = mw.ustring.sub( word,-1,-1 ) -- last letter
    local seclastl = mw.ustring.sub( word,-2,-2 ) 
    local thirdlastl = mw.ustring.sub( word, -3,-3 )
    local twolastl = mw.ustring.sub( word,-2,-1 )
    local threelastl = mw.ustring.sub( word,-3,-1 )
    
    if mw.ustring.match(threelastl,'lac') then
        return mw.ustring.sub( word,1,-4) .. 'oca'
    elseif mw.ustring.match(twolastl,'nj') or mw.ustring.match(twolastl,'lj') and mw.ustring.match(thirdlastl,'a') then
        return mw.ustring.sub( word,1,-4) .. twolastl .. 'a'
    elseif mw.ustring.match(lastl,'['..kons..']') and mw.ustring.match(seclastl,'a') then
        return mw.ustring.sub( word,1,-3) .. lastl .. 'a'  
    elseif mw.ustring.match(seclastl,'e') and mw.ustring.match(lastl,'o') then
        return mw.ustring.sub( word,1,-2) .. 'la'
    elseif mw.ustring.match(seclastl,'a') and mw.ustring.match(lastl,'o') then
        return mw.ustring.sub( word,1,-3) .. 'la'
    elseif mw.ustring.match(seclastl,'t') and mw.ustring.match(lastl,'e') then
        return word .. 'ta'
    elseif mw.ustring.match(lastl,'['..kons..']') or mw.ustring.match(lastl,'e') then
        return word .. 'a'
    elseif mw.ustring.match(lastl,'i') then
        return word .. 'ja'
    elseif mw.ustring.match(lastl,'o') then
        return mw.ustring.sub( word,1,-2) .. 'a'
    elseif mw.ustring.match(lastl,'a') then
        return mw.ustring.sub( word,1,-2) .. 'e'    
    end

    return word
end

return str