local export = {}
local consonants = {
='k' , ='kh' , ='g' , ='gh' , ='ṅ' , ='n̆g' , ='c' , ='ch' , ='j' , ='jh' ,
='ñ' , ='gn' , ='n̆j' , ='ṭ' , ='ṭh' , ='ḍ' , ='ḍh' , ='ṇ' , ='n̆ḍ' ,
='t' , ='th' , ='d' , ='dh' , ='n' , ='n̆d' ,
='p' , ='f' , ='ph' , ='b' , ='bh' , ='m' , ='m̆b' , ='y' , ='r' , ='l' , ='v' ,
='ś' , ='ṣ' , ='s' , ='h' , ='ḷ' , ='f'
}
local diacritics = {
= 'ā',
= 'æ',
= 'ǣ',
= 'i',
= 'ī',
= 'u',
= 'ū',
= 'e',
= 'ē',
= 'ai',
= 'o',
= 'ō',
= 'au',
= 'ṛ',
= 'ḷ',
= 'ṝ',
= 'ḹ',
= ''
}
local tt = {
-- vowels
='a' , ='ā' , ='æ' , ='ǣ' , ='i' , ='ī' , ='u' , ='ū' ,
='e' , ='ē' , ='ai' , ='o' , ='ō' , ='au' ,
='ṛ' , ='ṝ' , ='ḷ' , ='ḹ' ,
-- other symbols
='ṁ' , -- anusvara
='ḥ' , -- visarga
='' , --hal kirīma, supresses the inherent vowel "a"
-- punctuation
='.' , -- kunddaliya (obsolete)
}
-- translit any words or phrases
function export.tr(text)
if type(text) == 'table' then text = text.args end
text = mw.ustring.gsub(
text,
'()'..
'(?)',
function(c, d)
if d == "" then
return consonants .. 'a'
else
return consonants .. diacritics
end
end)
text = mw.ustring.gsub(text, '.', tt)
return text
end
return export