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 = "[" .. consonants .. "]"
local acute = U(0x301) -- combining acute
data["sa-Gujr"] = {
-- 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(0x0AC5),
["ઐ"] = 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["sa-Gujr"], {"(" .. 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-Gujr"], {"(" .. consonant .. ")અ", "%1"})
-- [[w:Harvard-Kyoto]] to [[w:International Alphabet of Sanskrit Transliteration]]
data["sa-Gujr-tr"] = {
[1] = {
["A"] = "ā",
["I"] = "ī",
["U"] = "ū",
["J"] = "ñ",
["T"] = "ṭ",
["D"] = "ḍ",
["N"] = "ṇ",
["G"] = "ṅ",
["z"] = "ś",
["S"] = "ṣ",
["M"] = "ṃ",
["H"] = "ḥ",
["lRR"] = "ḹ",
["/"] = acute,
},
[2] = {
["lR"] = "ḷ",
["RR"] = "ṝ",
},
[3] = {
["R"] = "ṛ",
},
}
return data