Springe nei ynhâld

Module:dv-translit

Ut Wikiwurdboek
local export = {}
local u = mw.ustring.char
 
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 = {
	[u(0x07A6)] = 'a', [u(0x07A7)] = 'ā', [u(0x07A8)] = 'i', [u(0x07A9)] = 'ī', [u(0x07AA)] = 'u',
	[u(0x07AB)] = 'ū', [u(0x07AC)] = 'e', [u(0x07AD)] = 'ē', [u(0x07AE)] = 'o', [u(0x07AF)] = 'ō', [u(0x07B0)] = '',
	-- no diacritic
	[''] = 'a'
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		'([ހ-ޥޱ])(['..u(0x07A6)..'-'..u(0x07B0)..']?)',
		function(c, d)
			return consonants[c] .. diacritics[d]
		end)
	return text
end
 
return export