وحدة:bn-translit
المظهر
-- 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', ['ষ'] = 'sh', ['স'] = 's', ['হ'] = 'h',
['য়'] = 'y', ['ড়'] = 'ŗ', ['ঢ়'] = 'ŗh',
-- vowel diacritics
['ি'] = 'i', ['ু'] = 'u', ['ৃ'] = 'ri', ['ে'] = 'e', ['ো'] = 'o',
['া'] = 'a', ['ী'] = 'i', ['ূ'] = 'u', ['ৈ'] = 'oi', ['ৌ'] = 'ow',
-- vowel signs
['অ'] = 'ô', ['ই'] = 'i', ['উ'] = 'u', ['ঋ'] = 'ri', ['এ'] = 'e', ['ও'] = 'o',
['আ'] = 'a', ['ঈ'] = 'i', ['ঊ'] = 'u', ['ঐ'] = 'oi', ['ঔ'] = 'ow',
-- chôndrôbindu
['ঁ'] = 'ṁ',
-- ônusbar
['ং'] = 'ṁ',
-- khôndô tô
['ৎ'] = 't',
-- numerals
['০'] = '0', ['১'] = '1', ['২'] = '2', ['৩'] = '3', ['৪'] = '4', ['৫'] = '5', ['৬'] = '6', ['৭'] = '7', ['৮'] = '8', ['৯'] = '9',
-- punctuation
['।'] = '.', -- dari
}
local nasal_assim = {
---????
}
local all_cons, special_cons = 'ক্ষজ্ঞকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলৱশষসহয়ড়ঢ়', '????'
local vowel, vowel_sign = 'িুৃেোাীূৈৌ', 'অইউঋএওআঈঊঐঔ'
local syncope_pattern = '([' .. vowel .. vowel_sign .. '])([' .. all_cons .. '])a([' .. gsub(all_cons, "य", "") .. '])(ं?[' .. vowel .. vowel_sign .. '])'
local function rev_string(text)
local result, length = '', mw.ustring.len(text)
for i = 1, length do
result = result .. mw.ustring.sub(text, length - i + 1, length - i + 1)
end
return result
end
function export.tr(text, lang, sc)
text = gsub(text, '([' .. all_cons .. ']़?)([' .. vowel .. '्]?)', function(c, d)
return c .. (d == "" and 'a' or d) end)
local result = {}
for word in mw.text.gsplit(text, " ", true) do
word = rev_string(word)
word = gsub(word, '^a(़?)([' .. all_cons .. '])(.)', function(opt, first, second)
return (((match(first, '[' .. special_cons .. ']') and match(second, '्')) or match(first .. second, 'य[ीेै]'))
and 'a' or "") .. opt .. first .. second end)
while match(word, syncope_pattern) do
word = gsub(word, syncope_pattern, '%1%2%3%4')
end
word = gsub(word, '(.?)ं(.)', function(succ, prev)
return succ .. (succ..prev == "a" and "????" or
(succ == "" and match(prev, '[' .. vowel .. ']') and "̃" or nasal_assim[succ] or "n")) .. prev end)
table.insert(result, rev_string(word))
end
text = table.concat(result, " ")
text = gsub(text, '???', conv)
return mw.ustring.toNFC(text)
end
return export