Module:tln-conj: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 30: | Line 30: | ||
pres_3p = "ᠡᠨ", | pres_3p = "ᠡᠨ", | ||
past_1s = " | past_1s = "ᠢ", | ||
past_2s = " | past_2s = "ᠢᠰᠲᠢ", | ||
past_3s = " | past_3s = "ᠢᠲ", | ||
past_1p = " | past_1p = "ᠢᠨᠤᠰ", | ||
past_2p = " | past_2p = "ᠢᠰᠲᠢᠰ", | ||
past_3p = " | past_3p = "ᠡᠷᠤᠨ" | ||
}, | }, | ||
| Line 165: | Line 165: | ||
.. '|-\n' | .. '|-\n' | ||
.. '! Indicative | .. '! rowspan="2" | Indicative\n' | ||
.. '! Present\n' | |||
.. '| ' .. make_cell(forms.pres_1s) | .. '| ' .. make_cell(forms.pres_1s) | ||
.. ' || ' .. make_cell(forms.pres_2s) | .. ' || ' .. make_cell(forms.pres_2s) | ||
| Line 179: | Line 180: | ||
.. '|-\n' | .. '|-\n' | ||
.. ' | .. '! Past\n' | ||
.. '| ' .. make_cell(forms.past_1s) | .. '| ' .. make_cell(forms.past_1s) | ||
.. ' || ' .. make_cell(forms.past_2s) | .. ' || ' .. make_cell(forms.past_2s) | ||
Revision as of 04:31, 20 June 2026
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local p = {}
----------------------------------------------------------------
-- ENDINGS
----------------------------------------------------------------
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§",
past_1s = "§P1S_ARE§",
past_2s = "§P2S_ARE§",
past_3s = "§P3S_ARE§",
past_1p = "§P1P_ARE§",
past_2p = "§P2P_ARE§",
past_3p = "§P3P_ARE§"
},
ere = {
pres_1s = "ᠣ",
pres_2s = "ᠡᠰ",
pres_3s = "ᠡᠲ",
pres_1p = "ᠡᠨᠤᠰ",
pres_2p = "ᠡᠴᠢᠰ",
pres_3p = "ᠡᠨ",
past_1s = "ᠢ",
past_2s = "ᠢᠰᠲᠢ",
past_3s = "ᠢᠲ",
past_1p = "ᠢᠨᠤᠰ",
past_2p = "ᠢᠰᠲᠢᠰ",
past_3p = "ᠡᠷᠤᠨ"
},
ire = {
pres_1s = "§1S_IRE§",
pres_2s = "§2S_IRE§",
pres_3s = "§3S_IRE§",
pres_1p = "§1P_IRE§",
pres_2p = "§2P_IRE§",
pres_3p = "§3P_IRE§",
past_1s = "§P1S_IRE§",
past_2s = "§P2S_IRE§",
past_3s = "§P3S_IRE§",
past_1p = "§P1P_IRE§",
past_2p = "§P2P_IRE§",
past_3p = "§P3P_IRE§"
}
}
----------------------------------------------------------------
-- CLASS DETECTION
----------------------------------------------------------------
local function detect_class(title)
if mw.ustring.match(title, "ᠠᠷᠡ$") then
return "are"
elseif mw.ustring.match(title, "ᠡᠷᠡ$") then
return "ere"
elseif mw.ustring.match(title, "ᠢᠷᠡ$") then
return "ire"
end
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
----------------------------------------------------------------
-- TRANSLITERATION
----------------------------------------------------------------
local translit = {
["ᠠ"] = "a",
["ᠡ"] = "e",
["ᠢ"] = "i",
["ᠣ"] = "o",
["ᠤ"] = "u",
["ᠷ"] = "r",
["ᠸ"] = "v",
["ᠵ"] = "z",
["ᠰ"] = "s",
["ᠲ"] = "t",
["ᠨ"] = "n",
["ᠴ"] = "č"
}
local function romanize(text)
local result = text
for bichig, latin in pairs(translit) do
result = mw.ustring.gsub(result, bichig, latin)
end
return result
end
----------------------------------------------------------------
-- DISPLAY HELPERS
----------------------------------------------------------------
local function make_cell(form)
return "<div style='text-align:center;'>"
.. "[[" .. form .. "]]"
.. "<br /><span style='color:#777777; font-size:90%;'>"
.. romanize(form)
.. "</span></div>"
end
----------------------------------------------------------------
-- MAIN FUNCTION
----------------------------------------------------------------
function p.show(frame)
local args = frame:getParent().args
local title = mw.title.getCurrentTitle().text
local class = args.class or detect_class(title)
if not class then
return "Error: could not determine conjugation class."
end
local stem = get_stem(title, class)
local forms = {}
for slot, ending in pairs(endings[class]) do
if args[slot] and args[slot] ~= "" then
forms[slot] = args[slot]
else
forms[slot] = stem .. ending
end
end
local text =
'{| class="wikitable mw-collapsible mw-collapsed"\n'
.. '|+ Conjugation of [[' .. title .. ']] (<span style="color:#777777;">' .. romanize(title) .. '</span>)\n'
----------------------------------------------------------------
-- HEADER
----------------------------------------------------------------
.. '|-\n'
.. '! Mood !! Tense !! colspan="3" | Singular !! colspan="3" | Plural\n'
.. '|-\n'
.. '! !! !! 1st !! 2nd !! 3rd !! 1st !! 2nd !! 3rd\n'
----------------------------------------------------------------
-- PRESENT
----------------------------------------------------------------
.. '|-\n'
.. '! rowspan="2" | Indicative\n'
.. '! Present\n'
.. '| ' .. make_cell(forms.pres_1s)
.. ' || ' .. make_cell(forms.pres_2s)
.. ' || ' .. make_cell(forms.pres_3s)
.. ' || ' .. make_cell(forms.pres_1p)
.. ' || ' .. make_cell(forms.pres_2p)
.. ' || ' .. make_cell(forms.pres_3p)
.. '\n'
----------------------------------------------------------------
-- PAST
----------------------------------------------------------------
.. '|-\n'
.. '! Past\n'
.. '| ' .. make_cell(forms.past_1s)
.. ' || ' .. make_cell(forms.past_2s)
.. ' || ' .. make_cell(forms.past_3s)
.. ' || ' .. make_cell(forms.past_1p)
.. ' || ' .. make_cell(forms.past_2p)
.. ' || ' .. make_cell(forms.past_3p)
.. '\n'
.. '|}'
return text
end
return p