local export = {}
local consonant_list = "kKgGNcCjJYwWqQRtTdDnpPbBmyrlLvSzsh"
local consonant = ""
local vowel_list = "aAiIuUfFxXeEoO"
local vowel = ""
local U = mw.ustring.char
local virAma = U(0x0DCA)
local diacritics = {
= '', = 'ා',
= 'ි', = 'ී',
= 'ු', = 'ූ',
= 'ෘ', = 'ෲ',
= 'ෟ', = 'ෳ',
= 'ෙ', = 'ෛ',
= 'ො', = 'ෞ',
}
local tt = {
-- consonants
= 'ක', = 'ඛ', = 'ග', = 'ඝ', = 'ඞ',
= 'ච', = 'ඡ', = 'ජ', = 'ඣ', = 'ඤ',
= 'ට', = 'ඨ', = 'ඩ', = 'ඪ', = 'ණ',
= 'ත', = 'ථ', = 'ද', = 'ධ', = 'න',
= 'ප', = 'ඵ', = 'බ', = 'භ', = 'ම',
= 'ය', = 'ර', = 'ල', = 'ව', = 'ළ',
= 'ශ', = 'ෂ', = 'ස', = 'හ',
-- vowels
= "අ", = "ආ",
= "ඉ", = "ඊ",
= "උ", = "ඌ",
= "ඍ", = "ඎ",
= "ඏ", = "ඐ",
= "එ", = "ඓ",
= "ඔ", = "ඖ",
-- chandrabindu
= 'ඁ',
-- anusvara
= 'ං',
-- visarga
= 'ඃ',
-- avagraha
-- = 'ऽ',
--numerals
--- Unchanged
-- = '०', = '१', = '२', = '३', = '४', = '५', = '६', = '७', = '८', = '९',
--Vedic extensions
-- = 'ᳵ',
-- = 'ᳶ',
= '',
= '',
}
-- local fixes = mw.loadData('Module:sa-utilities/translit/post replace fix/Sinh')
local fixes = require('Module:sa-utilities/translit/post replace fix/Sinh')
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)
-- Elaborate
for _, data in ipairs(fixes) do
text = mw.ustring.gsub(text, data, data)
end
return text
-- return mw.ustring.toNFC(text)
end
return export