বিষয়বস্তুতে চলুন

মডিউল:Brah-translit

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:Brah-translit/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

local consonants = {
--consonants
	['𑀓']='ক', ['𑀔']='খ', ['𑀕']='গ', ['𑀖']='ঘ', ['𑀗']='ঙ',
	['𑀘']='চ', ['𑀙']='ছ', ['𑀚']='জ', ['𑀛']='ঝ', ['𑀜']='ঞ', 
	['𑀝']='ট', ['𑀞']='ঠ', ['𑀟']='ড', ['𑀠']='ঢ', ['𑀡']='ণ', 
	['𑀢']='ত', ['𑀣']='থ', ['𑀤']='দ', ['𑀥']='ধ', ['𑀦']='ন', 
	['𑀧']='প', ['𑀨']='ফ', ['𑀩']='ব', ['𑀪']='ভ', ['𑀫']='ম',
	['𑀬']='য়', ['𑀭']='র', ['𑀮']='ল', ['𑀯']='ৱ', ['𑀴']='ল়',
	['𑀰']='শ', ['𑀱']='ষ', ['𑀲']='স', ['𑀳']='হ',
}

local diacritics = {
--matras
	['𑀸']='া', ['𑀺']='ি', ['𑀻']='ী', ['𑀼']='ু', ['𑀽']='ূ', ['𑀾']='ৃ', ['𑀿']='ৄ', 
	['𑁀']='ৢ', ['𑁁']='ৣ', ['𑁂']='ে', ['𑁃']='ৈ', ['𑁄']='ো', ['𑁅']='ৌ',  ['𑁆']='্',

    --bhattiprolu aa
    ['𑀹']='া়',

     --Old Tamil
    ['𑁳']='ে়', ['𑁴']='ো়',
}

local diatrema = {
	['𑀇']='ি়', ['𑀉']='ু়',
}

local tt = {

--vowels
	['𑀅']='অ', ['𑀆']='আ', ['𑀇']='ই', ['𑀈']='ঈ', ['𑀉']='উ', ['𑀊']='ঊ', ['𑀋']='ঋ', ['𑀌']='ৠ',
	['𑀍']='ঌ', ['𑀎']='ৡ', ['𑀏']='এ', ['𑀐']='ঐ', ['𑀑']='ও', ['𑀒']='ঔ', 
    ['𑁱']='এ়', ['𑁲']='ও়', --Old Tamil

	-- chandrabindu    
	['𑀀']='ঁ', --until a better method is found
	-- anusvara    
	['𑀁']='ং', --until a better method is found
	-- visarga    
	['𑀂']='ঃ',
	--numerals
	['𑁦']='০', ['𑁧']='১', ['𑁨']='২', ['𑁩']='৩', ['𑁪']='৪', ['𑁫']='৫', ['𑁬']='৬', ['𑁭']='৭', ['𑁮']='৮', ['𑁯']='৯',
	--punctuation        
	['𑁇']='।', --danda
    ['𑁈']='।।' --double danda
}

function export.tr(text, lang, sc)
	if sc ~= "Brah" then
		return nil
	end

	if lang == "inc-pra" then -- Route contextually shortened Prakrit vowels through Old Tamil short vowels
		text = mw.ustring.gsub(text, '(𑁂)([𑀅-𑀳]?)(𑁆)([𑀅-𑀳]?)', '𑁳%2%3%4')
		text = mw.ustring.gsub(text, '(𑀏)([𑀅-𑀳]?)(𑁆)([𑀅-𑀳]?)', '𑁱%2%3%4')
		text = mw.ustring.gsub(text, '(𑁄)([𑀅-𑀳]?)(𑁆)([𑀅-𑀳]?)', '𑁴%2%3%4')
		text = mw.ustring.gsub(text, '(𑀑)([𑀅-𑀳]?)(𑁆)([𑀅-𑀳]?)', '𑁲%2%3%4')
	end

	text = mw.ustring.gsub(
		text,
		'([𑀓-𑀴])'..
		'([𑀸𑀺𑀺𑀻𑀼𑀽𑀾𑀿𑁀𑁁𑁂𑁃𑁄𑁅𑁆𑀹𑁳𑁴]?)'..
		'([𑀇𑀉]?)',
		function(c, d, e)
			if d == "" and e ~= "" then
				return consonants[c] .. diatrema[e]
			elseif e ~= "" then
				return consonants[c] .. diacritics[d] .. tt[e]
			elseif d == "" then        
				return consonants[c]
			else
				return consonants[c] .. diacritics[d]
			end
		end)

-- Adjacent vowel letters needing dieresis
	text = mw.ustring.gsub(text, '([𑀅])([𑀇𑀉])', function(a, b) return tt[a]..diatrema[b] end)

	text = mw.ustring.gsub(text, '.', tt)

	return text
end
 
return export