Module:typing-aids/data/sa-Sidd



local data = {}

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

local anusvAra = U(0x115BD)
local visarga = U(0x115BE)
local virAma = U(0x115BF)
local avagraha = "ऽ"
local consonants = "𑖎𑖏𑖐𑖑𑖒𑖓𑖔𑖕𑖖𑖗𑖘𑖙𑖚𑖛𑖜𑖝𑖞𑖟𑖠𑖡𑖢𑖣𑖤𑖥𑖦𑖧𑖨𑖩𑖪𑖫𑖬𑖭𑖮"
local consonant = "[" .. consonants .. "]"

local acute = U(0x301)		-- combining acute

data["sa-Sidd"] = {
	-- Vowels and modifiers. Do the diphthongs and diaereses first.
	{"ai", "𑖋"},
	{"au", "𑖍"},
	{"ä", "𑖀"},
	{"ö", "𑖌"},
	{"ï", "𑖂"},
	{"ü", "𑖄"},
	{"a", "𑖀"},
	{"ā", "𑖁"},
	{"i", "𑖂"},
	{"ī", "𑖃"},
	{"u", "𑖄"},
	{"ū", "𑖅"},
	{"e", "𑖊"},
	{"o", "𑖌"},
	{"ṝ", "𑖇"},
	{"ṛ", "𑖆"},
	{"r̥", "𑖆"},
	{"ḹ", "𑖉"},
	{"ḷ", "𑖈"},
	{"(𑖀)[%-/]([𑖂𑖄])", "%1%2"},		-- a-i, a-u for अइ, अउ; must follow rules for "ai", "au"

	-- Two-letter consonants must go before h.
	{"kh", "𑖏"},
	{"gh", "𑖑"},
	{"ch", "𑖔"},
	{"jh", "𑖖"},
	{"ṭh", "𑖙"},
	{"ḍh", "𑖛"},
	{"th", "𑖞"},
	{"dh", "𑖠"},
	{"ph", "𑖣"},
	{"bh", "𑖥"},
	{"h", "𑖮"},

	-- Other stops.
	{"k", "𑖎"},
	{"g", "𑖐"},
	{"c", "𑖓"},
	{"j", "𑖕"},
	{"ṭ", "𑖘"},
	{"ḍ", "𑖚"},
	{"t", "𑖝"},
	{"d", "𑖟"},
	{"p", "𑖢"},
	{"b", "𑖤"},

	-- Nasals.
	{"ṅ", "𑖒"},
	{"ñ", "𑖗"},
	{"ṇ", "𑖜"},
	{"n", "𑖡"},
	{"n", "𑖡"},
	{"m", "𑖦"},

	-- Remaining consonants.
	{"y", "𑖧"},
	{"r", "𑖨"},
	{"l", "𑖩"},
	{"v", "𑖪"},
	{"ś", "𑖫"},
	{"ṣ", "𑖬"},
	{"s", "𑖭"},

	{"ṃ", anusvAra},
	{"ḥ", visarga},
	{"'", avagraha},
	-- This rule must be applied twice because a consonant may only be in one capture per operation,
	-- so "CCC" will only recognize the first two consonants. Must follow all consonant conversions.
	{"(" .. consonant .. ")(" .. consonant .. ")", "%1" .. virAma .. "%2"},
	{"(" .. consonant .. ")(" .. consonant .. ")", "%1" .. virAma .. "%2"},
	{"(" .. consonant .. ")$", "%1" .. virAma},
	{acute, ""},
}

local vowels = {
	["𑖂"] = U(0x115B0),
	["𑖃"] = U(0x115B1),
	["𑖄"] = U(0x115B2),
	["𑖅"] = U(0x115B3),
	["𑖆"] = U(0x115B4),
	["𑖇"] = U(0x115B5),
	["𑖊"] = U(0x115B8),
	["𑖋"] = U(0x115B9),
	["𑖌"] = U(0x115BA),
	["𑖍"] = U(0x115BB),
	["𑖁"] = U(0x115AF),
}

-- Convert independent vowels to diacritics after consonants. Must go after all consonant conversions.
for independentForm, diacriticalForm in pairs(vowels) do
	table.insert(data["sa-Sidd"], {"(" .. consonant .. ")" .. independentForm, "%1" .. diacriticalForm})
end

-- This must go last, after independent vowels are converted to diacritics, or "aï", "aü" won't work.
table.insert(data["sa-Sidd"], {"(" .. consonant .. ")𑖀", "%1"})

-- [[w:Harvard-Kyoto]] to [[w:International Alphabet of Sanskrit Transliteration]]
data["sa-Sidd-tr"] = {
	[1] = {
		["A"] = "ā",
		["I"] = "ī",
		["U"] = "ū",
		["J"] = "ñ",
		["T"] = "ṭ",
		["D"] = "ḍ",
		["N"] = "ṇ",
		["G"] = "ṅ",
		["z"] = "ś",
		["S"] = "ṣ",
		["M"] = "ṃ",
		["H"] = "ḥ",
		["lRR"] = "ḹ",
		["/"] = acute,
	},
	[2] = {
		["lR"] = "ḷ",
		["RR"] = "ṝ",
	},
	[3] = {
		["R"] = "ṛ",
	},
}

return data