Module:typing-aids/data/kn

local data = {}

local U = mw.ustring.char

local candrabindu = U(0xC81) local anusvAra = U(0xC82) local visarga = U(0xC83) local virAma = U(0xCCD) local avagraha = "ಽ" local consonants = "ಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲವಶಷಸಹಳೞ" local consonant = "[" .. consonants .. "]"

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

data["kn"] = { -- Vowels and modifiers. Do the diphthongs and diaereses first. {"ai", "ಐ"}, {"au", "ಔ"}, {"ï", "ಇ"}, {"ü", "ಉ"}, {"a", "ಅ"}, {"ā", "ಆ"}, {"i", "ಇ"}, {"ī", "ಈ"}, {"u", "ಉ"}, {"ū", "ಊ"}, {"e", "ಎ"}, {"ē", "ಏ"}, {"o", "ಒ"}, {"ō", "ಓ"}, {"ṝ", "ೠ"}, {"ṛ", "ಋ"}, {"r̥", "ಋ"}, {"ḹ", "ೡ"}, {"l̥", "ಌ"}, {"(ಅ)[%-/]([ಇಉ])", "%1%2"},		-- a-i, a-u for ಅಇ, ಅಉ; must follow rules for "ai", "au" {"(ಲ)[%-/]([ೃ ೄ])", "%1%2"},		-- l-R, l-RR for ಲೃ, ಲೄ; must follow rules for "lR", "lRR"

-- 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", "ನ"}, {"m", "ಮ"},

-- Remaining consonants. {"y", "ಯ"}, {"r", "ರ"}, {"l", "ಲ"}, {"v", "ವ"}, {"ś", "ಶ"}, {"ṣ", "ಷ"}, {"s", "ಸ"}, {"ḷ", "ಳ"},

{"m̐", candrabindu}, {"ṃ", 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(0xCBF), ["ಉ"] = U(0xCC1), ["ಋ"] = U(0xCC3), ["ಌ"] = U(0xCE2), ["ಎ"] = U(0xCC6), ["ಏ"] = U(0xCC7), ["ಎ"] = U(0xCCA), ["ಓ"] = U(0xCCB), ["ಆ"] = U(0xCBE), ["ಈ"] = U(0xCC0), ["ಊ"] = U(0xCC2), ["ೠ"] = U(0xCC4), ["ೡ"] = U(0xCE3), ["ಐ"] = U(0xCC8), ["ಔ"] = U(0xCCC), }

-- Convert independent vowels to diacritics after consonants. Must go after all consonant conversions. for independentForm, diacriticalForm in pairs(vowels) do table.insert(data["kn"], {"(" .. 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["kn"], {"(" .. consonant .. ")ಅ", "%1"})

data["kn-tr"] = { [1] = {		["A"] = "ā", ["I"] = "ī", ["U"] = "ū", ["E"] = "ē", ["O"] = "ō", ["J"] = "ñ", ["T"] = "ṭ", ["D"] = "ḍ", ["L"] = "ḷ", ["N"] = "ṇ", ["G"] = "ṅ", ["z"] = "ś", ["S"] = "ṣ", ["M"] = "ṃ", ["H"] = "ḥ", },	[2] = {		["lR"] = "l̥", ["lRR"] = "ḹ", },	[3] = {		["R"] = "ṛ", ["RR"] = "ṝ", }, }

return data