Mô đun:Mahj-translit
Giao diện
local export = {}
local consonants = {
['𑅕']='k', ['𑅖']='kh', ['𑅗']='g', ['𑅘']='gh',
['𑅙']='c', ['𑅚']='ch', ['𑅛']='j', ['𑅜']='jh', ['𑅝']='ñ',
['𑅞']='ṭ', ['𑅟']='ṭh', ['𑅠']='ḍ', ['𑅡']='ḍh', ['𑅢']='ṇ',
['𑅣']='t', ['𑅤']='th', ['𑅥']='d', ['𑅦']='dh', ['𑅧']='n',
['𑅨']='p', ['𑅩']='ph', ['𑅪']='b', ['𑅫']='bh', ['𑅬']='m',
['𑅭']='r', ['𑅮']='l', ['𑅯']='v',
['𑅰']='s', ['𑅱']='h', ['𑅲'] = 'ṛ',
}
local nonconsonants = {
-- vowels
['𑅐']='a', ['𑅑']='i', ['𑅒']='u', ['𑅓']='e', ['𑅔']='o',
-- other symbols
['𑅴']='.', -- abbreviation mark
['𑅵']='§', -- section mark
['𑅶']='Shri', -- ligature [[श्री]]
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([𑅕𑅖𑅗𑅘𑅙𑅚𑅛𑅜𑅝𑅞𑅟𑅠𑅡𑅢𑅣𑅤𑅥𑅦𑅧𑅨𑅩𑅪𑅫𑅬𑅭𑅮𑅯𑅰𑅱𑅲])'..
'([𑅳]?)',
function(c, d)
-- mw.log('match', c, d)
return (consonants[c] or c)
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
return text
end
return export