Module:Deva-Kthi-translit

This module will transliterate text in the Devanagari script.

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:Deva-Kthi-translit/testcases.

FunctionsEdit

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 conv = {
	['क']='𑂍', ['ख']='𑂎', ['ग']='𑂏', ['घ']='𑂐', ['ङ']='𑂑',
	['च']='𑂒', ['छ']='𑂓', ['ज']='𑂔', ['झ']='𑂕', ['ञ']='𑂖', 
	['ट']='𑂗', ['ठ']='𑂘', ['ड']='𑂙', ['ढ']='𑂛', ['ण']='𑂝',
	['त']='𑂞', ['थ']='𑂟', ['द']='𑂠', ['ध']='𑂡', ['न']='𑂢', 
	['प']='𑂣', ['फ']='𑂤', ['ब']='𑂥', ['भ']='𑂦', ['म']='𑂧',
	['य']='𑂨', ['र']='𑂩', ['ल']='𑂪', ['व']='𑂫',
	['श']='𑂬', ['ष']='𑂭', ['स']='𑂮', ['ह']='𑂯',

	['ा']='𑂰', ['ि']='𑂱', ['ी']='𑂲', ['ु']='𑂳', ['ू']='𑂴', ['े']='𑂵', ['ै']='𑂶', ['ो']='𑂷', ['ौ']='𑂸',  ['्']='𑂹', ['़']='𑂺',

	-- vowels
	['अ']='𑂃', ['आ']='𑂄', ['इ']='𑂅', ['ई']='𑂆', ['उ']='𑂇', ['ऊ']='𑂈', ['ऋ']='𑂩𑂲', ['ए']='𑂉', ['ऐ']='𑂊', ['ओ']='𑂋', ['औ']='𑂌', 
	-- chandrabindu    
	['ँ']='𑂀',
	-- anusvara    
	['ं']='𑂁',
	-- visarga    
	['ः']='𑂂',
	--punctuation        
    ['॥']='𑃁',
	['।']='𑃀',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		".",
		function(c)
			return conv[c]
		end)

	return text
end
 
return export