Module:dv-translit

ពីWiktionary

Documentation for this module may be created at Module:dv-translit/doc

local export = {}
 
local consonants = {
	['ހ']='h', ['ށ']='sh' , ['ނ']='n' , ['ރ']='r' , ['ބ']='b' ,
	['ޅ']='ḷ' , ['ކ']='k' , ['އ']='' , ['ވ']='v' , ['މ']='m' ,
	['ފ']='f' , ['ދ']='d' , ['ތ']='t' , ['ލ']='l' , ['ގ']='g' ,
	['ޏ']='ñ' , ['ސ']='s' , ['ޑ']='ḍ' , ['ޒ']='z' , ['ޓ']='ṭ' , 
	['ޔ']='y' , ['ޕ']='p' , ['ޖ']='j' , ['ޗ']='c' , ['ޱ']='ṇ' , 
	['ޘ']='ṯ' , ['ޙ']='ḥ' , ['ޚ']='x' , ['ޛ']='ź' , ['ޜ']='ž' , 
	['ޝ']='š' , ['ޞ']='ş' , ['ޟ']='ḋ' , ['ޠ']='ţ' , ['ޡ']='ẓ' , 
	['ޢ']='ʿ' , ['ޣ']='ġ' , ['ޤ']='q' , ['ޥ']='w' ,

}

local diacritics = {
	['\222\166']='a' , ['\222\167']='ā' , ['\222\168']='i' , ['\222\169']='ī' , ['\222\170']='u' , 
	['\222\171'] = 'ū' , ['\222\172']='e' , ['\222\173']='ē' , ['\222\174']='o' , ['\222\175']='ō' , ['\222\176']='',
	-- no diacritic
	[""] = 'a'
}


-- translit any words or phrases
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		'([ހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޱޘޙޚޛޜޝޞޟޠޡޢޣޤޥ])'..
		'([\222\166\222\167\222\168\222\169\222\170\222\171\222\172\222\173\222\174\222\175\222\176]?)',
		function(c, d)
			return consonants[c] .. diacritics[d]
		end)
	return text
end
 
return export