local export = {}
local consonants = {
='k', ='kh', ='g', ='gh', ='ng',
='c', ='ch', ='j', ='jh', ='ñ',
='ṭ', ='ṭh', ='ḍ', ='ḍh', ='ṇ',
='t', ='th', ='d', ='dh', ='n',
='p', ='ph', ='b', ='bh', ='m',
='y', ='r', ='ṟ', ='l', ='v', ='ś',
='ṣ', ='s', ='h', ='ḷ', ='ḻ',
='f', ='z', ='zh',
}
local diacritics = {
= 'ā' , ='i' , ='ī' , ='u' , ='ū' , ='r̥' , ='r̥̄' ,
='e' , ='ē' , ='ai' , ='o' , ='ō' , ='au'
}
local nonconsonants = {
-- vowels
='a' , ='ā' , ='i' , ='ī' , ='u' , ='ū' ,
='r̥' , ='r̥̄' , ='l̥' , ='l̥̄', ='e' , ='ē' ,
='ai' , ='o' , ='ō' , ='au' , ='aṃ' , ='ah' ,
-- other symbols
='ṃ', -- anusvara
='ḥ', -- visarga
--halant, supresses the inherent vowel "a"
='',
-- digits
= '0', = '1', = '2', = '3', = '4',
= '5', = '6', = '7', = '8', = '9',
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'(?)'..
'(?)',
function(c, d)
-- mw.log('match', c, d)
c = consonants or c
if d == "" then
return c .. 'a'
else
return c .. (diacritics or d)
end
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export