Module:sa-utilities/translit/SLP1-to-Deva

Hello, you have come here looking for the meaning of the word Module:sa-utilities/translit/SLP1-to-Deva. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:sa-utilities/translit/SLP1-to-Deva, but we will also tell you about its etymology, its characteristics and you will know how to say Module:sa-utilities/translit/SLP1-to-Deva in singular and plural. Everything you need to know about the word Module:sa-utilities/translit/SLP1-to-Deva you have here. The definition of the word Module:sa-utilities/translit/SLP1-to-Deva will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:sa-utilities/translit/SLP1-to-Deva, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local consonant_list = "kKgGNcCjJYwWqQRtTdDnpPbBmyrlLvSzsh"
local consonant = ""
local vowel_list = "aAiIuUfFxXeEoO"
local vowel = ""

local U = require("Module:string/char")

local virAma = U(0x94D)

local diacritics = {
	 = '',  = 'ा',
	 = 'ि',  = 'ी',
	 = 'ु',  = 'ू',
	 = 'ृ',  = 'ॄ',
	 = 'ॢ',  = 'ॣ',
	 = 'े',  = 'ै',
	 = 'ो',  = 'ौ',
}

local tt = {
	-- consonants
	 = 'क',  = 'ख',  = 'ग',  = 'घ',  = 'ङ',
	 = 'च',  = 'छ',  = 'ज',  = 'झ',  = 'ञ',
	 = 'ट',  = 'ठ',  = 'ड',  = 'ढ',  = 'ण',
	 = 'त',  = 'थ',  = 'द',  = 'ध',  = 'न',
	 = 'प',  = 'फ',  = 'ब',  = 'भ',  = 'म',
	 = 'य',  = 'र',  = 'ल',  = 'व',  = 'ळ',
	 = 'श',  = 'ष',  = 'स',  = 'ह',
	-- vowels
	 = "अ",  = "आ",
	 = "इ",  = "ई",
	 = "उ",  = "ऊ",
	 = "ऋ",  = "ॠ",
	 = "ऌ",  = "ॡ",
	 = "ए",  = "ऐ",
	 = "ओ",  = "औ",
	-- chandrabindu
	 = 'ँ',
	-- anusvara
	 = 'ं',
	-- visarga
	 = 'ः',
	-- avagraha
	 = 'ऽ',
	--numerals
	 = '०',  = '१',  = '२',  = '३',  = '४',  = '५',  = '६',  = '७',  = '८',  = '९',
	--Vedic extensions
	 = 'ᳵ',
	 = 'ᳶ',
	 = '',
	 = '',
}

function export.tr(text, lang, sc)
	-- capture twice so that all adjacent pairs are covered
	text = mw.ustring.gsub(text, "(" .. consonant .. ")" .. "(" .. consonant .. ")", "%1" .. virAma .. "%2")
	text = mw.ustring.gsub(text, "(" .. consonant .. ")" .. "(" .. consonant .. ")", "%1" .. virAma .. "%2")
	-- whitespace and end of string
	text = mw.ustring.gsub(text, "(" .. consonant .. ")%f", "%1" .. virAma)
	-- all vowel diacritics
	text = mw.ustring.gsub(text, "(" .. consonant .. ")(" .. vowel ..  ")", function(c, v) return c .. diacritics end)
	-- everything else
	text = mw.ustring.gsub(text, '.', tt)
	return mw.ustring.toNFC(text)
end

return export