This module will transliterate text in the 馬哈佳尼文. 它被用於轉寫馬瓦里語。 The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:Mahj-translit/testcases.

Functions

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', 
	['𑅭']='r', ['𑅮']='l', ['𑅯']='v',
	['𑅰']='s', ['𑅱']='h', ['𑅲'] = 'ṛ',
}

local nonconsonants = {
	-- vowels
	['𑅐']='a', ['𑅑']='i', ['𑅒']='u', ['𑅓']='e', ['𑅔']='o',

	-- other symbols
	['𑅴‎']='.', -- abbreviation mark
	['𑅵']='§', -- section mark
	['𑅶']='Shri', -- ligature [[श्री]]
}

-- translit any words or phrases
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		'([𑅕𑅖𑅗𑅘𑅙𑅚𑅛𑅜𑅝𑅞𑅟𑅠𑅡𑅢𑅣𑅤𑅥𑅦𑅧𑅨𑅩𑅪𑅫𑅬𑅭𑅮𑅯𑅰𑅱𑅲])'..
		'([𑅳]?)',
		function(c, d)
			-- mw.log('match', c, d)
			return (consonants[c] or c)
		end)
	
	text = mw.ustring.gsub(text, '.', nonconsonants)
	
	return text
end
 
return export