local data = {}
local U = require("Module:string/char")
local anusvAra = U(0x0A82)
local visarga = U(0x0A83)
local virAma = U(0x0ACD)
local avagraha = "ઽ"
local consonants = "કખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલવળશષસહ"
local consonant = ""
local acute = U(0x301) -- combining acute
data = {
-- 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", "ન"},
{"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(0x0ABE),
= U(0x0ABF),
= U(0x0AC0),
= U(0x0AC1),
= U(0x0AC2),
= U(0x0AC3),
= U(0x0AC4),
= U(0x0AC7),
= U(0x0AC8),
= U(0x0AE2),
= U(0x0AE3),
= U(0x0ACB),
= U(0x0ACC),
}
-- Convert independent vowels to diacritics after consonants. Must go after all consonant conversions.
for independentForm, diacriticalForm in pairs(vowels) do
table.insert(data, {"(" .. 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, {"(" .. consonant .. ")અ", "%1"})
-- ] to ]
data = {
= {
= "ā",
= "ī",
= "ū",
= "ñ",
= "ṭ",
= "ḍ",
= "ṇ",
= "ṅ",
= "ś",
= "ṣ",
= "ṃ",
= "ḥ",
= "ḹ",
= acute,
},
= {
= "ḷ",
= "ṝ",
},
= {
= "ṛ",
},
}
return data