Module:tln-conj: Difference between revisions

Nehster9 (talk | contribs)
Created page with "local p = {} local endings = { are = { pres_1s = "§1S_ARE§", pres_2s = "§2S_ARE§", pres_3s = "§3S_ARE§", pres_1p = "§1P_ARE§", pres_2p = "§2P_ARE§", pres_3p = "§3P_ARE§" }, ere = { pres_1s = "§1S_ERE§", pres_2s = "§2S_ERE§", pres_3s = "§3S_ERE§", pres_1p = "§1P_ERE§", pres_2p = "§2P_ERE§", pres_3p = "§3P_ERE§" }, ire = { p..."
 
Nehster9 (talk | contribs)
mNo edit summary
Line 31: Line 31:


local function detect_class(title)
local function detect_class(title)
     if mw.ustring.match(title, "are$") then
 
     if mw.ustring.match(title, "ᠠᠷᠡ$") then
         return "are"
         return "are"
     elseif mw.ustring.match(title, "ere$") then
 
     elseif mw.ustring.match(title, "ᠡᠷᠡ$") then
         return "ere"
         return "ere"
     elseif mw.ustring.match(title, "ire$") then
 
     elseif mw.ustring.match(title, "ᠢᠷᠡ$") then
         return "ire"
         return "ire"
     end
     end


     return nil
     return nil
end
local function get_stem(title, class)
    if class == "are" then
        return mw.ustring.gsub(title, "ᠠᠷᠡ$", "")
    elseif class == "ere" then
        return mw.ustring.gsub(title, "ᠡᠷᠡ$", "")
    elseif class == "ire" then
        return mw.ustring.gsub(title, "ᠢᠷᠡ$", "")
    end
    return title
end
end


Line 52: Line 70:
     local title = mw.title.getCurrentTitle().text
     local title = mw.title.getCurrentTitle().text


     local class = detect_class(title)
     local class = args.class or detect_class(title)


     if not class then
     if not class then
Line 58: Line 76:
     end
     end


     local stem = mw.ustring.gsub(title, class .. "$", "")
     local stem = get_stem(title, class)


     local forms = {}
     local forms = {}
Line 78: Line 96:
         '! !! Singular !! Plural\n' ..
         '! !! Singular !! Plural\n' ..
         '|-\n' ..
         '|-\n' ..
         '! First\n' ..
         '! First person\n' ..
         '| ' .. make_link(forms.pres_1s) ..
         '| ' .. make_link(forms.pres_1s) ..
         ' || ' .. make_link(forms.pres_1p) .. '\n' ..
         ' || ' .. make_link(forms.pres_1p) .. '\n' ..
         '|-\n' ..
         '|-\n' ..
         '! Second\n' ..
         '! Second person\n' ..
         '| ' .. make_link(forms.pres_2s) ..
         '| ' .. make_link(forms.pres_2s) ..
         ' || ' .. make_link(forms.pres_2p) .. '\n' ..
         ' || ' .. make_link(forms.pres_2p) .. '\n' ..
         '|-\n' ..
         '|-\n' ..
         '! Third\n' ..
         '! Third person\n' ..
         '| ' .. make_link(forms.pres_3s) ..
         '| ' .. make_link(forms.pres_3s) ..
         ' || ' .. make_link(forms.pres_3p) .. '\n' ..
         ' || ' .. make_link(forms.pres_3p) .. '\n' ..