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

মডিউল:or-translit

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

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

local export = {}

local consonants = {
	--common
	["କ"]="ক", ["ଖ"]="খ", ["ଗ"]="গ", ["ଘ"]="ঘ", ["ଙ"]="ঙ",
	["ଚ"]="চ", ["ଛ"]="ছ", ["ଜ"]="জ", ["ଝ"]="ঝ", ["ଞ"]="ঞ", 
	["ଟ"]="ট", ["ଠ"]="ঠ", ["ଡ"]="ড", ["ଢ"]="ঢ", ["ଣ"]="ণ", 
	["ତ"]="ত", ["ଥ"]="থ", ["ଦ"]="দ", ["ଧ"]="ধ", ["ନ"]="ন", 
	["ପ"]="প", ["ଫ"]="ফ", ["ବ"]="ব", ["ଭ"]="ভ", ["ମ"]="ম",
	["ଯ"]="য", ["ୟ"]="য়", ["ର"]="র", ["ଲ"]="ল", ["ଳ"]="ল়",
	["ଵ"]="ৱ", ["ୱ"]="ৱ", ["ଶ"]="শ", ["ଷ"]="ষ", ["ସ"]="স", ["ହ"]="হ",
	--nuktas
	["କ଼"]="ক়", ["ଖ଼"]="খ়", ["ଗ଼"]="গ়", ["ଜ଼"]="জ়", ["ଝ଼"]="ঝ়",
	["ଡ଼"]="ড়", ["ଢ଼"]="ঢ়", ["ଫ଼"]="ফ়",
}

local diacritics = {
	["ା"]="া", ["ି"]="ি", ["ୀ"]="ী", ["ୁ"]="ু", ["ୂ"]="ূ", ["ୃ"]="ৃ", ["ୄ"]="ৄ",
	["ୢ"]="ৢ", ["ୣ"]="ৣ", ["େ"]="ে", ["ୈ"]="ৈ", ["ୖ"]="ৈ", ["ୋ"]="ো", ["ୌ"]="ৌ", ["ୗ"]="ৗ",
	["୍"]="্",
}

local tt = {
	-- vowels
	["ଅ"]="অ", ["ଆ"]="আ", ["ଇ"]="ই", ["ଈ"]="ঈ", ["ଉ"]="উ", ["ଊ"]="ঊ", ["ଋ"]="ঋ", ["ୠ"]="ৠ",
	["ଌ"]="ঌ", ["ୡ"]="ৡ", ["ଏ"]="এ", ["ଐ"]="ঐ", ["ଓ"]="ও", ["ଔ"]="ঔ", 
	-- chandrabindu    
	["ଁ"]="ঁ", --until a better method is found
	-- anusvara    
	["ଂ"]="ং", --until a better method is found
	-- visarga    
	["ଃ"]="ঃ",
	-- avagraha
	["ଽ"]="ঽ",
	--numerals
	["୦"]="০", ["୧"]="১", ["୨"]="২", ["୩"]="৩", ["୪"]="৪", ["୫"]="৫", ["୬"]="৬", ["୭"]="৭", ["୮"]="৮", ["୯"]="৯",
	["୲"]="১/৪", ["୳"]="১/২", ["୴"]="৩/৪", ["୵"]="১/১৬", ["୶"]="১/৮", ["୷"]="৩/১৬",
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		"([କଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଵଭମଯୟରଲଳୱଶଷସହ]଼?)"..
		"([ାିୀୁୂୃୄେୈୖୋୌୗ୍ୢୣ]?)",
		function(c, d)
			if not consonants[c] then
				return c
			end
			if d == "" then
				return consonants[c]
			else
				return consonants[c] .. diacritics[d]
			end
		end)

	text = mw.ustring.gsub(text, ".", tt)
	
	return text
end
 
return export