বিষয়বস্তুতে চলুন

মডিউল:en-translit/খেলাঘর

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:en-translit/খেলাঘর/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match

local conv = {
	-- ব্যঞ্জনবর্ণ
	-- ছোট হাতের অক্ষর
	['b'] = 'ব', ['d'] = 'ড', ['f'] = 'ফ', ['h'] = 'হ', ['j'] = 'জ',
	['k'] = 'ক', ['l'] = 'ল', ['m'] = 'ম', ['n'] = 'ন', ['p'] = 'প',
	['q'] = 'ক', ['r'] = 'র', ['s'] = 'স', ['t'] = 'ট', ['v'] = 'ভ',
	['w'] = 'ৱ', ['x'] = 'ক্স', ['z'] = 'জ়',

	-- বড় হাতের অক্ষর
	['B'] = 'ব', ['D'] = 'ড', ['F'] = 'ফ়', ['H'] = 'হ', ['J'] = 'জ',
	['K'] = 'ক', ['L'] = 'ল', ['M'] = 'ম', ['N'] = 'ন', ['P'] = 'প',
	['Q'] = 'ক', ['R'] = 'র', ['S'] = 'স', ['T'] = 'ট', ['V'] = 'ভ়',
	['W'] = 'ৱ', ['X'] = 'ক্স', ['Z'] = 'জ়',

	-- স্বরবর্ণ
	-- ছোট হাতের অক্ষর
	['a'] = 'এই', ['e'] = 'ঈ', ['i'] = 'আই', ['o'] = 'ওউ', ['u'] = 'ইউ', ['y'] = 'য়',

	-- বড় হাতের অক্ষর
	['A'] = 'এই', ['E'] = 'ঈ', ['I'] = 'আই', ['O'] = 'ওউ', ['U'] = 'ইউ', ['Y'] = 'য়',

}

local cons = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZকখগঘঙচজঝঞটডথদনপফবভমরলশসহয়' .. '়?'
local bn_cons = 'কখগঘঙচজঝঞটডথদনপফবভমরলশসহয়' .. '়?'
local C = 'cg'
local vow = 'aeiouyঈউীু'

local function rev_string(text)
	local result, length = {}, mw.ustring.len(text)
	for i = length, 1, -1 do
		table.insert(result, mw.ustring.sub(text, i, i))
	end
	return table.concat(result)
end

function export.tr(text, lang, sc)
	-- ch, ph, sh, th
	text = gsub(text, '[cC]h', 'চ')
	text = gsub(text, '[pP]h', 'ফ়')
	text = gsub(text, '[sS]h', 'শ')
	text = gsub(text, '[tT]h', 'থ')
	-- wh
	text = gsub(text, '[wW]ha', 'হোয়া')
	text = gsub(text, '[wW]hi', 'হুই')
	text = gsub(text, '[wW]ho', 'হো')

	-- dg
	text = gsub(text, 'dg', 'jj')

	-- igh
	text = gsub(text, '([' .. cons .. '])igh', '%1াই')

	-- সফট ও হার্ড c
	text = gsub(text, '[cC]e', 'se')
	text = gsub(text, '[cC]i', 'si')
	text = gsub(text, '[cC]y', 'sy')
	text = gsub(text, '[cC]', 'k')

	-- সফট ও হার্ড g
	text = gsub(text, 'gg[eiy]', 'g%1')
	text = gsub(text, '[gG]e', 'je')
	text = gsub(text, '[gG]i', 'ji')
	text = gsub(text, '[gG]y', 'jy')
	text = gsub(text, '[gG]', 'গ')

	-- ee, oo
	text = gsub(text, '^ee', 'ঈ')
	text = gsub(text, '^oo', 'উ')

	text = gsub(text, 'ee', 'ী')
	text = gsub(text, 'oo', 'ু')

	-- ar, er
	text = gsub(text, '^ar', 'আr')
	text = gsub(text, 'ar', 'াr')

	text = gsub(text, '^er', 'অ্যr')
	text = gsub(text, 'er', '্যr')

	-- tele
	text = gsub(text, '^tele', 'টেলি')

	-- x
	text = gsub(text, '^x', 'z')
	text = gsub(text, 'ex([' .. vow .. '])', 'egz%1')
	text = gsub(text, 'xc', 'ks')

	-- e ব্যতীত অন্যান্য অনুচ্চারিত বর্ণের বিলোপ
	text = gsub(text, '^[kgm]n', 'n')
	text = gsub(text, '^wr', 'r')

	text = gsub(text, '([' .. cons .. '])y([' .. cons .. '])e$', '%1াই%2')
	text = gsub(text, '^([' .. cons .. '])([' .. cons .. '])y$', '%1%2াই')

	-- হ্রস্ব স্বর
	text = gsub(text, '([' .. cons .. '])a([' .. cons .. '])$', '%1্যা%2')
	text = gsub(text, '([' .. cons .. '])e([' .. cons .. '])$', '%1ে%2')
	text = gsub(text, '([' .. cons .. '])i([' .. cons .. '])$', '%1ি%2')
	text = gsub(text, '([' .. cons .. '])o([' .. cons .. '])$', '%1%2')
	text = gsub(text, '([' .. cons .. '])u([' .. cons .. '])$', '%1া%2')
	text = gsub(text, '([' .. cons .. '])y([' .. cons .. '])$', '%1ি%2')

	text = gsub(text, '^a([' .. cons .. '])([' .. cons .. '])', 'অ্যা%1%2')
	text = gsub(text, '^e([' .. cons .. '])([' .. cons .. '])', 'এ%1%2')
	text = gsub(text, '^i([' .. cons .. '])([' .. cons .. '])', 'ই%1%2')
	text = gsub(text, '^o([' .. cons .. '])([' .. cons .. '])', 'অ%1%2')
	text = gsub(text, '^u([' .. cons .. '])([' .. cons .. '])', 'আ%1%2')
	text = gsub(text, '^y([' .. cons .. '])([' .. cons .. '])', 'ই%1%2')

	text = gsub(text, '^A([' .. cons .. '])([' .. cons .. '])', 'অ্যা%1%2')
	text = gsub(text, '^E([' .. cons .. '])([' .. cons .. '])', 'এ%1%2')
	text = gsub(text, '^I([' .. cons .. '])([' .. cons .. '])', 'ই%1%2')
	text = gsub(text, '^O([' .. cons .. '])([' .. cons .. '])', 'অ%1%2')
	text = gsub(text, '^U([' .. cons .. '])([' .. cons .. '])', 'আ%1%2')
	text = gsub(text, '^Y([' .. cons .. '])([' .. cons .. '])', 'ই%1%2')

	text = gsub(text, '([' .. cons .. '])a([' .. cons .. '])([' .. cons .. '])', '%1্যা%2%3')
	text = gsub(text, '([' .. cons .. '])e([' .. cons .. '])([' .. cons .. '])', '%1ে%2%3')
	text = gsub(text, '([' .. cons .. '])i([' .. cons .. '])([' .. cons .. '])', '%1ি%2%3')
	text = gsub(text, '([' .. cons .. '])o([' .. cons .. '])([' .. cons .. '])', '%1%2%3')
	text = gsub(text, '([' .. cons .. '])u([' .. cons .. '])([' .. cons .. '])', '%1া%2%3')
	text = gsub(text, '([' .. cons .. '])y([' .. cons .. '])([' .. cons .. '])', '%1ি%2%3')

	-- sio, ssio, tio
	text = gsub(text, 'isio', 'িঝ়্য')
	text = gsub(text, 'sio', 'ঝ়্য')

	text = gsub(text, 'ssio', 'শ্য')

	text = gsub(text, 'atio', 'েইশ্য')
	text = gsub(text, 'tio', 'শ্য')

	-- ব্যঞ্জনবর্ণের দ্বিত্ব
	text = gsub(text, 'bb', 'b')
	text = gsub(text, 'cc[aou]', 'c%1')
	text = gsub(text, 'dd', 'd')
	text = gsub(text, 'ff', 'f')
	text = gsub(text, 'gg', 'g')
	text = gsub(text, 'jj', 'j')
	text = gsub(text, 'kk', 'k')
	text = gsub(text, 'll', 'l')
	text = gsub(text, 'mm', 'm')
	text = gsub(text, 'nn', 'n')
	text = gsub(text, 'pp', 'p')
	text = gsub(text, 'rr', 'r')
	text = gsub(text, 'ss', 's')
	text = gsub(text, 'tt', 't')
	text = gsub(text, 'vv', 'v')
	text = gsub(text, 'zz', 'z')

	-- le, re
	text = gsub(text, '[lr]e$', '্য%1')

	-- যুক্তাক্ষর
	text = gsub(text, '([' .. cons .. '])([' .. cons .. '])', '%1্%2')

	-- অনুচ্চারিত e-এর বিলোপ
	text = gsub(text, 'e$', '')

	-- হসন্ত
	text = gsub(text, '([' .. cons .. '])$', '%1্')

	text = gsub(text, '.', conv)

	text = gsub(text, '([' .. bn_cons .. '])অ', '%1')
	text = gsub(text, '([' .. bn_cons .. '])আ', '%1া')
	text = gsub(text, '([' .. bn_cons .. '])ই', '%1ি')
	text = gsub(text, '([' .. bn_cons .. '])ঈ', '%1ী')
	text = gsub(text, '([' .. bn_cons .. '])উ', '%1ু')
	text = gsub(text, '([' .. bn_cons .. '])ঊ', '%1ূ')
	text = gsub(text, '([' .. bn_cons .. '])এ', '%1ে')
	text = gsub(text, '([' .. bn_cons .. '])ও', '%1ো')

	text = gsub(text, '([' .. bn_vow .. '])আ', '%1য়া')

	return mw.ustring.toNFC(text)
end

return export