Masaram Gondi transliteration module.


Module:gon-Gonm-translit/testcases:

All tests passed. (refresh)

လိက် ဗွဲမရံၚ်လၟဳ မဇေတ်ဍာံ တၚ်လညာတ်ဂမၠိုၚ်
test_translit_gondi:
Passed 𑴦𑴶 independent <r̥> represented by independent <r> + dependent <r̥>
Passed 𑴨𑴘𑵂𑴳 vaṛī vaṛī <ṛ> represented as 𑴘𑵂
Passed 𑴀𑴎𑵅𑴎 agga agga virama
Passed 𑴌𑴱𑴖𑵄 kāṭ kāṭ word-final halanta
Passed 𑴌𑴵𑴥𑵄𑴫𑴱 kūysā kūysā word-medial halanta
Passed 𑴀𑵆𑴝𑴽 ardo ardo repha
Passed 𑴑𑴱𑴠𑵇𑴱 cāprā cāprā ra-kāra
Passed 𑴆𑵃 ĕ ĕ <ऍ> ĕ independent
Passed 𑴁𑵃 ŏ ŏ <ऑ> ŏ independent
Passed 𑴌𑵃 <ऍ> ĕ dependent
Passed 𑴌𑴱𑵃 <ऑ> ŏ dependent

local export = {}
local gsub = mw.ustring.gsub
 
local consonants = {
	['𑴌'] = 'k', ['𑴍'] = 'kh', ['𑴎'] = 'g', ['𑴏'] = 'gh', ['𑴐'] = 'ṅ', 
	['𑴑'] = 'c', ['𑴒'] = 'ch', ['𑴓'] = 'j', ['𑴔'] = 'jh', ['𑴕'] = 'ñ', 
	['𑴖'] = 'ṭ', ['𑴗'] = 'ṭh', ['𑴘'] = 'ḍ', ['𑴙'] = 'ḍh', ['𑴚'] = 'ṇ', 
	['𑴛'] = 't',  ['𑴜'] = 'th', ['𑴝'] = 'd', ['𑴞'] = 'dh', ['𑴟'] = 'n',
	['𑴠'] = 'p', ['𑴡'] = 'ph', ['𑴢'] = 'b', ['𑴣'] = 'bh', ['𑴤'] = 'm', 
	['𑴥'] = 'y', ['𑴦'] = 'r', ['𑴧'] = 'l', ['𑴨'] = 'v', ['𑴭'] = 'ḷ',
	['𑴩'] = 'ś', ['𑴪'] = 'ṣ', ['𑴫'] = 's', ['𑴬'] = 'h', 
	['𑴮'] = 'kṣ', ['𑴯'] = 'jñ', ['𑴰'] = 'tr',
	['𑴘𑵂'] = 'ṛ',
}

local diacritics = {
	['𑴱'] = 'ā', ['𑴲'] = 'i', ['𑴳'] = 'ī', ['𑴴'] = 'u', ['𑴵'] ='ū', ['𑴶'] = 'r̥',
	['𑴺'] = 'e', ['𑴼'] = 'ai', ['𑴽'] ='o', ['𑴿'] = 'au', ['𑵄'] = '', ['𑵅'] = '',
}
local tt = {
	-- vowels
	['𑴀'] = 'a' , ['𑴁'] = 'ā' , ['𑴂'] = 'i' , ['𑴃'] = 'ī' , ['𑴄']='u' , ['𑴅'] = 'ū',
	['𑴆'] = 'e', ['𑴈'] = 'ai' , ['𑴉'] = 'o', ['𑴋'] = 'au',
	-- other symbols
	['𑵀'] = 'ṁ', -- anusvara
	['𑵁'] = 'ḥ', -- visarga
	['𑵃'] = '̃',  -- chandra

-- digits
	['𑵐'] = '0', ['𑵑'] = '1', ['𑵒'] = '2', ['𑵓'] = '3', ['𑵔'] = '4',
	['𑵕'] = '5', ['𑵖'] = '6', ['𑵗'] = '7', ['𑵘'] = '8', ['𑵙'] = '9',
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	text = gsub(text, '𑵇', '𑵄𑴦') -- ra-kāra
	text = gsub(
		text,
		'([𑴌-𑴰]𑵂?)'..
		'([[𑴱𑴲𑴳𑴴𑴵𑴶𑴺𑴼𑴽𑴿𑵀𑵁𑵄𑵅]?)',
		function(c, d)
			if d == "" then        
				return consonants[c] .. 'a'
			else
				return consonants[c] .. diacritics[d]
			end
		end)
	
	text = gsub(text, '.', tt)
	
	-- anusvara
	text = gsub(text, 'ṁ([kgṅ])', 'ṅ%1')
	text = gsub(text, 'ṁ([cjñ])', 'ñ%1')
	text = gsub(text, 'ṁ([ṭḍṇ])', 'ṇ%1')
	text = gsub(text, 'ṁ([tdn])', 'n%1')
	text = gsub(text, 'ṁ([pbm])', 'm%1')

	text = gsub(text, 'rr̥', 'r̥') -- 𑴦𑴶 is independent r̥
	text = gsub(text, '𑵆', 'r') -- repha

	text = gsub(text, '[ea]̃', 'ĕ') -- <ऍ> ĕ independent and dependent
	text = gsub(text, 'ā̃', 'ŏ') -- <ऑ> ŏ independent and dependent
	
	return text
end
 
return export