local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
local cons = 'ʾʿʔʕbdḍḏfgḡhḥjkḵlḷmnpqrsṣštṭṯvwyzẓ'
function export.show(frame)
-- get arguments
local args = frame:getParent().args
local form = frame.args or error("Verb form (arg 1) has not been specified.")
local pasttr = frame.args or error("Past transliteration (arg 2) has not been specified.")
local subjtr = frame.args or error("Subjunctive transliteration (arg 3) have not been specified.")
local past = frame.args or PAGENAME
-- prepare arguments
past = mw.ustring.gsub(past, '', '') -- remove tashkil
pasttr = mw.ustring.gsub(mw.ustring.gsub(pasttr, 'e', 'i'), 'o', 'u') -- change vowels e, o into i, u
subjtr = mw.ustring.gsub(mw.ustring.gsub(subjtr, 'e', 'i'), 'o', 'u') -- change vowels e, o into i, u
subjtr = mw.ustring.gsub(subjtr, '^b?y(.+)$', '%1') -- get subjunctive/present root
-- find out type of root
local tdef = mw.ustring.match(past, '.+()$') -- defective root (fa3a/fi3i)
local thol = mw.ustring.match(past, '.+(ا).$') -- hollow root (faal)
local tdbl = mw.ustring.match(pasttr, '.+$') -- doubled root (fall)
local treg = false
if form == '2' or form == '5' then
past = mw.ustring.sub(past, 1, -2) .. 'ّ' .. mw.ustring.sub(past, -1, -1) -- add shadda after middle root letter
end
-- define variants of the past root
local past2 = past
local past2tr = pasttr
local past3ftr = mw.ustring.gsub(pasttr, '^(.*)()$', '%1%2') -- remove medial vowel i/u
local past3ptr = past3ftr
-- define variants of the subj/pres root
local sjvow = mw.ustring.match(subjtr, '^()') -- prefix vowel
local subj = mw.ustring.gsub(past, '^', '')
if form == '4' then
subj = mw.ustring.gsub(subj, '^', '')
end
if sjvow == 'ā' then -- ʔakal and ʔaḵad
subj = mw.ustring.gsub(subj, '^أ', 'ا')
elseif sjvow and sjvow ~= 'a' then -- change seat of hamza after the vowels i, u
subj = mw.ustring.gsub(subj, '^', sjvow == 'i' and 'ئ' or 'ؤ')
end
local subj2 = subj
local subj2tr = subjtr
local bpref = sjvow and 'b' or 'bi' -- b-prefix
-- special treatment by root type
if tdef then -- defective
past2 = mw.ustring.sub(past, 1, -2) .. 'ي'
past2tr = mw.ustring.sub(pasttr, 1, -2) .. (tdef == 'ي' and 'ī' or 'ē')
past3ftr = mw.ustring.sub(pasttr, 1, -2)
past3ptr = mw.ustring.sub(pasttr, 1, -2) .. (tdef == 'ي' and 'y' or '')
subj2 = mw.ustring.gsub(subj, '$', '')
subj2tr = mw.ustring.gsub(subjtr, '$', '')
if tdef == 'ي' and mw.ustring.sub(subjtr, -1, -1) == 'a' then
subj = subj2..'ى'
elseif tdef == 'ى' and mw.ustring.sub(subjtr, -1, -1) == 'i' then
subj = subj2..'ي'
end
elseif thol then -- hollow
local sjhvow = mw.ustring.match(subjtr, '()')
past2 = mw.ustring.gsub(past, '^(.+)ا(.)$', '%1%2')
past2tr = mw.ustring.gsub(pasttr, '^(.+)ā(.)$', '%1i%2')
subj = mw.ustring.sub(past, -3, -3) .. (sjhvow == 'ā' and 'ا' or (sjhvow == 'ū' and 'و' or 'ي')) .. mw.ustring.sub(past, -1, -1)
elseif tdbl then -- doubled
past = past .. 'ّ'
past2 = past .. 'ي'
past2tr = pasttr .. 'ē'
else -- sound/regular
treg = true
subj2tr = mw.ustring.gsub(subj2tr, '(?)()', '%1%2')
end
-- define imperative roots
local imp = mw.ustring.gsub(mw.ustring.gsub(subj, '^ا', ''), '', 'أ')
local imp2 = mw.ustring.gsub(mw.ustring.gsub(subj2, '^ا', ''), '', 'أ')
local imptr = mw.ustring.gsub(subjtr, '^', '')
local imp2tr = mw.ustring.gsub(subj2tr, '^', '')
-- special imperative in form I regular/sound and defective
if form == '1' then
if treg then
local sjrvow = mw.ustring.match(subjtr, '()$')
imp = mw.ustring.sub(imp, 1, -2) .. (sjrvow == 'a' and 'ا' or (sjrvow == 'u' and 'و' or 'ي')) .. mw.ustring.sub(subj, -1, -1)
imptr = mw.ustring.sub(imptr, 1, -3) .. (sjrvow == 'a' and 'ā' or (sjrvow == 'u' and 'ō' or 'ē')) .. mw.ustring.sub(subjtr, -1, -1)
imptr = mw.ustring.gsub(imptr, '^ū', 'w')
imp2tr = mw.ustring.gsub(subjtr, '^(.+a)$', '%1')
imp2tr = mw.ustring.gsub(imp2tr, '^u(.+)()$', '%1u%2')
imp2tr = mw.ustring.gsub(imp2tr, '^(.+)()$', '%1i%2')
imp2tr = mw.ustring.gsub(imp2tr, '^ū', 'w')
elseif tdef then
imptr = mw.ustring.sub(imptr, 1, -2) .. (tdef == 'ي' and 'ī' or 'ā')
imp2tr = imp2tr .. 'ˉ'
end
end
-- i/u disappears when stress shifts
past2tr = mw.ustring.gsub(past2tr, '()u()i(?)$', '%1%2u%3') -- stressed i becomes u in emphatic environment
past2tr = mw.ustring.gsub(past2tr, '()(?)$', '%1%2')
-- output values in arabic script
local res_ar = {}
res_ar = past
res_ar = mw.ustring.gsub(past, '$', '')..'ت'
res_ar = mw.ustring.gsub(past, '$', '')..'و'
res_ar = past2..'ت'
res_ar = past2..'تي'
res_ar = past2..'تو'
res_ar = past2..'ت'
res_ar = past2..'نا'
res_ar = 'ي'..subj
res_ar = 'ت'..subj
res_ar = 'ي'..subj2..'و'
res_ar = 'ت'..subj
res_ar = 'ت'..subj2..'ي'
res_ar = 'ت'..subj2..'و'
res_ar = mw.ustring.gsub(((sjvow and (form == '1' or form == '4')) and (sjvow == 'i' and 'إ' or sjvow and 'أ') or '')..subj, 'أا', 'آ')
res_ar = 'ن'..subj
res_ar = 'بي'..subj
res_ar = 'بت'..subj
res_ar = 'بي'..subj2..'و'
res_ar = 'بت'..subj
res_ar = 'بت'..subj2..'ي'
res_ar = 'بت'..subj2..'و'
res_ar = 'ب'..subj
res_ar = 'من'..subj
res_ar = imp
res_ar = imp2..'ي'
res_ar = imp2..'و'
-- output values in transliteration
local res_tr = {}
res_tr = pasttr
res_tr = past3ftr..'it'
res_tr = past3ptr..'u'
res_tr = past2tr..'t'
res_tr = past2tr..'ti'
res_tr = past2tr..'tu'
res_tr = past2tr..'t'
res_tr = past2tr..'na'
res_tr = 'y'..subjtr
res_tr = 't'..subjtr
res_tr = 'y'..subj2tr..'u'
res_tr = 't'..subjtr
res_tr = 't'..subj2tr..'i'
res_tr = 't'..subj2tr..'u'
res_tr = mw.ustring.gsub(((sjvow and (form == '1' or form == '4')) and 'ʔ' or '')..subjtr, '^i', '')
res_tr = 'n'..subjtr
res_tr = bpref..(sjvow and 'y' or '')..subjtr
res_tr = bpref..'t'..subjtr
res_tr = bpref..(sjvow and 'y' or '')..subj2tr..'u'
res_tr = bpref..'t'..subjtr
res_tr = bpref..'t'..subj2tr..'i'
res_tr = bpref..'t'..subj2tr..'u'
res_tr = 'b'..subjtr
res_tr = mw.ustring.gsub(bpref, 'b', 'm')..'n'..subjtr
res_tr = imptr
res_tr = mw.ustring.gsub(imp2tr..'i', 'ˉi', 'ī')
res_tr = mw.ustring.gsub(imp2tr..'u', 'ˉu', 'ū')
return
'<table class="wikitable vsSwitcher vsToggleCategory-conjugation autocollapsed" style="text-align:center; border: 0.5px solid #CCC;">' ..
'<tr><th class="vsToggleElement" style="text-align:left; width:40em" colspan="9">    Conjugation of <i class="Arab mention" lang="ajp">'..past..'</i></th></tr>' ..
'<tr class="vsHide"><th colspan="2"></th><th colspan="3">singular</th><td rowspan="10"></td><th colspan="3">plural</th></tr>' ..
'<tr class="vsHide"><th colspan="2"></th><th>1<sup>st</sup> person</th><th>2<sup>nd</sup> person</th><th>3<sup>rd</sup> person</th><th>1<sup>st</sup> person</th><th>2<sup>nd</sup> person</th><th>3<sup>rd</sup> person</th></tr>' ..
'<tr class="vsHide">' ..
' <th rowspan="2">past</th><th><span class="gender"><abbr title="masculine gender">m</abbr></span></th>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span> (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'<tr class="vsHide">' ..
' <th><span class="gender"><abbr title="feminine gender">f</abbr></span></th>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'<tr class="vsHide">' ..
' <th rowspan="2">present</th><th><span class="gender"><abbr title="masculine gender">m</abbr></span></th>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'<tr class="vsHide">' ..
' <th><span class="gender"><abbr title="feminine gender">f</abbr></span></th>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'<tr class="vsHide">' ..
' <th rowspan="2">subjunctive</th><th><span class="gender"><abbr title="masculine gender">m</abbr></span></th>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'<tr class="vsHide"><th><span class="gender"><abbr title="feminine gender">f</abbr></span></th>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'<tr class="vsHide"><th rowspan="2">imperative</th><th><span class="gender"><abbr title="masculine gender">m</abbr></span></th>' ..
' <td rowspan="2"></td><td><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"></td><td rowspan="2"></td>' ..
' <td rowspan="2"><span class="Arab form-of lang-apc" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td>' ..
' <td rowspan="2"></td></tr>' ..
'<tr class="vsHide">' ..
' <th><span class="gender"><abbr title="feminine gender">f</abbr></span></th>' ..
' <td><span class="Arab form-of lang-apc 2|f|s|imperative-form-of" lang="ajp">'..res_ar..'</span>‎ (<span lang="ajp-Latn" class="tr Latn">'..res_tr..'</span>)</td></tr>' ..
'</table>'
end
return export