မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:kxv-translit

နူ ဝိက်ရှေန်နရဳ
ထာမ်ပလိက်တဏအ်ဒးနွံကဵုလိက်စၟတ်သမ္တီမချူလဝ်သာဓက။
သ္ပဂုန်တုဲထာမ်ပလိက်တဏအ်ဒးစၟတ်သမ္တီကဵုလိက်မချူလဝ်နူကဵုဓမံက်ထ္ၜးကဵုဗီုပြၚ်ကိစ္စမရန်တၟအ်လဝ် ကဵု ပရေၚ်မရပ်စပ်လ္တူမုက်လိက်နကဵုလိက်စၟတ်သမ္တီမချူလဝ်သာဓက

Module:kxv-IPA/testcases:

All tests passed. (refresh)

လိက် ဗွဲမရံၚ်လၟဳ မဇေတ်ဍာံ တၚ်လညာတ်ဂမၠိုၚ်
test_translit_kuvi:
Passed ଅଡୁ oḍu oḍu independent ଅ is o
Passed ଓଡୁ oḍu oḍu independent ଓ is o
Passed ଅ୕ଡୁ ōḍu ōḍu independent ଅ୕ is ō
Passed ଓଓଡୁ ōḍu ōḍu independent ଓଓ is ō
Passed ଆକୁ aku aku independent ଆ is a
Passed ଆ୕କୁ āku āku independent ଆ୕ is ā
Passed ଆଆକୁ āku āku independent ଆଆ is ā
Passed ଏସ୍କି eski eski independent ଏ is e
Passed ଏ୕ସ୍କି ēski ēski independent ଏ୕ is ē
Passed ଏଏସ୍କି ēski ēski independent ଏଏ is ē
Passed କଡି koḍi koḍi dependent ଅ/ଓ is o
Passed କ୕ଡି kōḍi kōḍi dependent ଅ୕ is ō
Passed କୋଓଡି kōḍi kōḍi dependent ଓଓ is ō
Passed ବାଲା bala bala dependent ଆ is a
Passed ବା୕ଲା bāla bāla dependent ଆ୕ is ā
Passed ବଆଲା bāla bāla dependent ଆଆ is ā
Passed ମେଣ୍ଡା meṇḍa meṇḍa dependent ଏ is e
Passed ମେ୕ଣ୍ଡା mēṇḍa mēṇḍa dependent ଏ୕ is ē
Passed ମେଏଣ୍ଡା mēṇḍa mēṇḍa dependent ଏଏ is ē
Passed ଇଇ ī ī independent ଇଇ is ī
Passed ଉଉ ū ū independent ଉଉ is ū
Passed କିଇ dependent ଇଇ is ī
Passed କୁଉ dependent ଉଉ is ū
Passed କୁଃଏ kuʔe kuʔe glottal stop ʔ
Passed ବିସେୟିଁ biseyĩ biseyĩ chandrabindu

local export = {}
local gsub = mw.ustring.gsub

local consonants = {
	--common
	["କ"]="k", ["ଖ"]="kh", ["ଗ"]="g", ["ଘ"]="gh", ["ଙ"]="ṅ",
	["ଚ"]="c", ["ଛ"]="ch", ["ଜ"]="j", ["ଝ"]="jh", ["ଞ"]="ñ", 
	["ଟ"]="ṭ", ["ଠ"]="ṭh", ["ଡ"]="ḍ", ["ଢ"]="ḍh", ["ଣ"]="ṇ", 
	["ତ"]="t", ["ଥ"]="th", ["ଦ"]="d", ["ଧ"]="dh", ["ନ"]="n", 
	["ପ"]="p", ["ଫ"]="ph", ["ବ"]="b", ["ଭ"]="bh", ["ମ"]="m",
	["ଯ"]="j", ["ୟ"]="y", ["ର"]="r", ["ଲ"]="l", ["ଳ"]="ḷ",
	["ଵ"]="v", ["ୱ"]="w", ["ଶ"]="ś", ["ଷ"]="ṣ", ["ସ"]="s", ["ହ"]="h",
	--nuktas
	["କ଼"]="q", ["ଖ଼"]="x", ["ଗ଼"]="ġ", ["ଜ଼"]="z", ["ଝ଼"]="ź",
	["ଡ଼"]="ṛ", ["ଢ଼"]="ṛh", ["ଫ଼"]="f",
}

local diacritics = {
	["ା"]="a", ["ି"]="i", ["ୀ"]="ī", ["ୁ"]="u", ["ୂ"]="ū", ["ୃ"]="ru", ["ୄ"]="rū", 
	["ୢ"]="lu", ["ୣ"]="lū", ["େ"]="e", ["ୈ"]="oi", ["ୖ"]="oi", ["ୋ"]="o", ["ୌ"]="ou", ["ୗ"]="ou",
	["୍"]="",
}

local tt = {
	-- vowels
	["ଅ"]="o", ["ଆ"]="a", ["ଇ"]="i", ["ଈ"]="ī", ["ଉ"]="u", ["ଊ"]="ū", ["ଋ"]="ru", ["ୠ"]="rū",
	["ଌ"]="lu", ["ୡ"]="lū", ["ଏ"]="e", ["ଐ"]="oi", ["ଓ"]="o", ["ଔ"]="ou",
	-- chandrabindu    
	["ଁ"]="̃", --until a better method is found
	-- anusvara    
	["ଂ"]="ṁ", --until a better method is found
	-- visarga    
	["ଃ"]="ʔ",
	-- avagraha
	["ଽ"]="’",
	--numerals
	["୦"]="0", ["୧"]="1", ["୨"]="2", ["୩"]="3", ["୪"]="4", ["୫"]="5", ["୬"]="6", ["୭"]="7", ["୮"]="8", ["୯"]="9",
	["୲"]="¼", ["୳"]="½", ["୴"]="¾", ["୵"]="¹⁄₁₆", ["୶"]="⅛", ["୷"]="³⁄₁₆",
	--punctuation        
	["।"]=".", --danda
}

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

	text = mw.ustring.gsub(text, ".", tt)
	
	-- anusvara
	text = gsub(text, 'ṁ([kqxgġṅ])', 'ṅ%1')
	text = gsub(text, 'ṁ([cjźñ])', 'ñ%1')
	text = gsub(text, 'ṁ([ṭḍṇ])', 'ṇ%1')
	text = gsub(text, 'ṁ([tdnz])', 'n%1')
	text = gsub(text, 'ṁ([pfbm])', 'm%1')

	-- long vowels
	text = gsub(text, '([oaāiue])%1', '%1̄') -- VV → V̄ 
	text = gsub(text, '([oea])୕', '%1̄')
	text = gsub(text, 'oa', 'ā') 
	text = gsub(text, 'aā', 'ā')

	return mw.ustring.toNFC(text)
	
end
 
return export