Documentation for this module may be created at မဝ်ဂျူ:mxi-translit/doc

local export = {};

function export.tr(text, lang, sc)

	local replacements;
	
	if (sc == 'Arab') then
		return mw.ustring.gsub(mw.ustring.gsub(text, '.', {
			-- consonants --
			['ا']='ə', ['ب']='b', ['ت']='t', ['ث']='ṯ', ['ج']='j',
			['ح']='ḥ', ['خ']='ḵ', ['د']='d', ['ذ']='ḏ', ['ر']='r',
			['ز']='z', ['س']='s', ['ش']='š', ['ص']='ṣ', ['ض']='ḍ',
			['ط']='ṭ', ['ظ']='ẓ', ['ع']='ʕ', ['غ']='ḡ', ['ڢ']='f',
			['ڧ']='q', ['ك']='k', ['ل']='l', ['م']='m', ['ࢽ']='n',
			['ه']='h', ['و']='w', ['ی']='y',
			-- [ق], [ف] and [ي] should not occur, but [ن] sometimes does
			['ن']='n',
			-- [ے] should likely be used in quotes at least
			['ے']='y',

			-- tashkil --
			['َ']='a', ['ُ']='u', ['ِ']='i',
			['ّ']='ː', ['ْ']='°',
		}), '([btṯjḥḵdḏrzsšṣḍṭẓʕḡfqklmnhwyuiː°])ə', '%1ā'):gsub('aə', 'ā');
	elseif (sc == 'Hebr') then
		return mw.ustring.gsub(text, '.', {

			-- consonants --
			['א'] = 'ʔ', ['ב'] = 'b', ['ג'] = 'g', ['ד'] = 'd',
			['ה'] = 'h', ['ו'] = 'w', ['ז'] = 'z', ['ח'] = 'ḥ',
			['ט'] = 'ṭ', ['י'] = 'y', ['כ'] = 'k', ['ל'] = 'l',
			['מ'] = 'm', ['נ'] = 'n', ['ס'] = 's', ['ע'] = 'ʕ',
			['פ'] = 'f', ['צ'] = 'ṣ', ['ק'] = 'q', ['ר'] = 'r',
			['ש'] = 'š', ['ת'] = 't',

			-- sofit --
			['ך'] = 'k', ['ם'] = 'm', ['ן'] = 'n', ['ף'] = 'f',
			['ץ'] = 'ṣ',

			-- nikud ?

		});
	end

	return ;

end

return export;