Jump to content

မေႃႇၵျူး:sa-utilities/translit/Deva-to-SLP1

လုၵ်ႉတီႈ ဝိၵ်ႇသျိၼ်ႇၼရီႇ မႃး
ထႅမ်းပလဵတ်ႉ ဢၼ်ၼႆႉ တိုၵ်ႉလူဝ်ႇ ၽိုၼ်ၵႅမ်မိုဝ်းမၼ်း။
ၶႅၼ်းတေႃႈ တႅမ်ႈပၼ် ၽိုၼ်ၵႅမ်မိုဝ်း ထႅမ်းပလဵတ်ႉ ဢၼ်ၼႆႉ သေ ၼႄပၼ် လွင်ႈယိူင်းဢၢၼ်း လႄႈ လၢႆးၸႂ်ႉတိုဝ်း ၵႃႈတီႈ ၼႃႈလိၵ်ႈ ၽိုၼ်ၵႅမ်မိုဝ်း သေၵမ်း။

local export = {}

local consonants = {
	['क'] = 'k', ['ख'] = 'K', ['ग'] = 'g', ['घ'] = 'G', ['ङ'] = 'N',
	['च'] = 'c', ['छ'] = 'C', ['ज'] = 'j', ['झ'] = 'J', ['ञ'] = 'Y',
	['ट'] = 'w', ['ठ'] = 'W', ['ड'] = 'q', ['ढ'] = 'Q', ['ण'] = 'R',
	['त'] = 't', ['थ'] = 'T', ['द'] = 'd', ['ध'] = 'D', ['न'] = 'n',
	['प'] = 'p', ['फ'] = 'P', ['ब'] = 'b', ['भ'] = 'B', ['म'] = 'm',
	['य'] = 'y', ['र'] = 'r', ['ल'] = 'l', ['व'] = 'v', ['ळ'] = 'L',
	['श'] = 'S', ['ष'] = 'z', ['स'] = 's', ['ह'] = 'h',
}

local diacritics = {
	['्'] = '', ['ा'] = 'A',
	['ि'] = 'i', ['ी'] = 'I',
	['ु'] = 'u', ['ू'] = 'U',
	['ृ'] = 'f', ['ॄ'] = 'F',
	['ॢ'] = 'x', ['ॣ'] = 'X',
	['े'] = 'e', ['ै'] = 'E',
	['ो'] = 'o', ['ौ'] = 'O',
}

local tt = {
	-- vowels
	['अ'] = 'a', ['आ'] = 'A',
	['इ'] = 'i', ['ई'] = 'I',
	['उ'] = 'u', ['ऊ'] = 'U',
	['ऋ'] = 'f', ['ॠ'] = 'F',
	['ऌ'] = 'x', ['ॡ'] = 'X',
	['ए'] = 'e', ['ऐ'] = 'E',
	['ओ'] = 'o', ['औ'] = 'O',
	-- chandrabindu
	['ँ'] = '~',
	-- anusvara
	['ं'] = 'M',
	-- visarga
	['ः'] = 'H',
	-- avagraha
	['ऽ'] = '',
	--numerals
	['०'] = '0', ['१'] = '1', ['२'] = '2', ['३'] = '3', ['४'] = '4', ['५'] = '5', ['६'] = '6', ['७'] = '7', ['८'] = '8', ['९'] = '9',
	--punctuation
	['॥'] = '.', --double danda
	['।'] = '.', --danda
	--Vedic extensions
	['ᳵ'] = 'Z',
	['ᳶ'] = 'V',
	--Om
	['ॐ'] = 'oM',
	['◌॑'] = '/',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text,
		'([कखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसह])' ..
				'([ािीुूृॄॢॣेैोौ्]?)',
		function(c, d)
			if d == "" then
				return consonants[c] .. 'a'
			else
				return consonants[c] .. diacritics[d]
			end
		end)
	
	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end

return export