-- Transliteration for Bengali
local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local conv = {
-- consonants
= 'kkh', = 'gg',
= 'k', = 'kh', = 'g', = 'gh', = 'ṅ',
= 'c', = 'ch', = 'j', = 'jh', = 'ñ',
= 'ṭ', = 'ṭh', = 'ḑ', = 'ḑh', = 'ṇ',
= 't', = 'th', = 'd', = 'dh', = 'n',
= 'p', = 'ph', = 'b', = 'bh', = 'm',
= 'j', = 'r', = 'l', = 'w',
= 'ś', = 'ṣ', = 's', = 'h',
= 'y', = 'ṛ', = 'ṛh',
-- visarga
= 'ḥ',
-- vowel diacritics
= 'i', = 'u', = 'ri', = 'e', = 'o',
= 'a', = 'i', = 'u', = 'oi', = 'ou',
-- vowel signs
= 'ô', = 'i', = 'u', = 'ri', = 'e', = 'o',
= 'a', = 'i', = 'u', = 'oi', = 'ou',
--hôshôntô
= '',
-- chôndrôbindu
= 'ṁ',
-- ônusbar
= 'N',
-- khôndô tô
= 't',
-- numerals
= '0', = '1', = '2', = '3', = '4', = '5', = '6', = '7', = '8', = '9',
-- punctuation
= '.', -- dari
}
function export.tr(text, lang, sc)
local c = '(়?)'
local y = 'য়'
local r = 'র'
local v = '()'
local virama = '্'
local n = '(ং?)'
local no_virama = mw.ustring.gsub(v,virama,"")
text = text .. " "
text = mw.ustring.gsub(text,c,"%1ô")
text = mw.ustring.gsub(text,"ô"..v,"%1")
text = mw.ustring.gsub(text,v..n..c.."ô ",function(j,k,l) --ending
return l==y and j..k..l.."ô " or j..k..l.." "
end)
local pattern = v..n..c.."ô"..c .. no_virama
local continue = true
while continue do
continue = false
text = mw.ustring.gsub(text,"(.*)"..pattern,function(d,e,f,g,h,i)
if g~=y and g~=r then
continue = true
end
return (g==y or g==r) and d..e..f..g.."ô"..h..i or d..e..f..g..h..i
end)
end
text = mw.ustring.gsub(text,"(়)",conv)
text = mw.ustring.gsub(text,"ক্ষ","kkh")
text = mw.ustring.gsub(text,"জ্ঞ","gg")
text = mw.ustring.gsub(text,".",conv)
text = mw.ustring.gsub(text,"ː(.)","%1%1")
text = mw.ustring.gsub(text," ?।",".")
text = mw.ustring.gsub(text,"(y)ô ","%1 ")
text = gsub(text,"ôN ","ông ")
text = gsub(text,"N","ng")
text = mw.ustring.gsub(text,"()b","%1")
text = mw.ustring.gsub(text," $","")
return mw.ustring.toNFC(text)
end
return export