這個模組會將莫迪文文字轉寫為拉丁字母。

最好不要直接從模板或其他模組調用此模組。要從模板中使用它,請以{{xlit}}做為替代;若要在模組中使用,則以Module:languages#Language:transliterate替代。

關於測試用例,請參閱Module:Modi-translit/testcases

函數

编辑
tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang. When the transliteration fails, returns nil.

local export = {}

local consonants = {
	['𑘎']='k', ['𑘏']='kh', ['𑘐']='g', ['𑘑']='gh', ['𑘒']='ṅ',
	['𑘓']='c', ['𑘔']='ch', ['𑘕']='j', ['𑘖']='jh', ['𑘗']='ñ', 
	['𑘘']='ṭ', ['𑘙']='ṭh', ['𑘚']='ḍ', ['𑘛']='ḍh', ['𑘜']='ṇ', 
	['𑘝']='t', ['𑘞']='th', ['𑘟']='d', ['𑘠']='dh', ['𑘡']='n', 
	['𑘢']='p', ['𑘣']='ph', ['𑘤']='b', ['𑘥']='bh', ['𑘦']='m',
	['𑘧']='y', ['𑘨']='r', ['𑘩']='l', ['𑘪']='v', ['𑘯']='ḷ',
	['𑘫']='ś', ['𑘬']='ṣ', ['𑘭']='s', ['𑘮']='h',
}

local diacritics = {
	['𑘰']='ā', ['𑘱']='i', ['𑘲']='ī', ['𑘳']='u', ['𑘴']='ū', ['𑘵']='ṛ', ['𑘶']='ṝ', 
	['𑘷']='ḷ', ['𑘸']='ḹ', ['𑘹']='e', ['𑘺']='ai', ['𑘻']='o', ['𑘼']='au',
	-- virama
	['𑘿'] = '',
}

local tt = {
	-- vowel signs
	['𑘀'] = 'a', ['𑘂'] = 'i', ['𑘄'] = 'u', ['𑘊'] = 'e', ['𑘌'] = 'o',
	['𑘁'] = 'ā', ['𑘃'] = 'ī', ['𑘅'] = 'ū', 
	['𑘆'] = 'ŕ', 
	['𑘋'] = 'ai', ['𑘍'] = 'au', 
	['𑘁𑙀'] = 'ŏ',
	['𑘀𑙀'] = 'ĕ', ['𑘊𑙀'] = 'ĕ',
	-- anusvara
	['𑘽'] = 'ṃ',
	-- visarga
	['𑘾'] = 'ḥ',
	-- numerals
	['𑙐'] = '0', ['𑙑'] = '1', ['𑙒'] = '2', ['𑙓'] = '3', ['𑙔'] = '4', ['𑙕'] = '5', ['𑙖'] = '6', ['𑙗'] = '7', ['𑙘'] = '8', ['𑙙'] = '9',
	--punctuation        
	['𑙁'] = '.', -- danda
	['𑙂'] = '.', -- double danda
	['+'] = '', -- compound separator
	
	-- abbreviation sign
	['𑙃'] = '.',
    --Om
    ['ॐ']='oṃ',
}

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)
	text = mw.ustring.gsub(text," ?[𑙁𑙂]",".")

	
	return text
end
 
return export