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

-- বাংলা উইকিঅভিধানের জন্য, প্রদত্ত লেখার সাথে "ের" সামঞ্জস্যবিধান

local appends = {
	-- 'র'
	['া'] = 'র',
	['ি'] = 'র',
	['ী'] = 'র',
	['ু'] = 'র',
	['ূ'] = 'র',
	['ৃ'] = 'র',
	['ে'] = 'র',
	['ৈ'] = 'র',
	['ো'] = 'র',
	['ৌ'] = 'র',
	-- 'ের'
	['ক'] = 'ের',
	['খ'] = 'ের',
	['গ'] = 'ের',
	['ঘ'] = 'ের',
	['ঙ'] = 'ের',
	['চ'] = 'ের',
	['ছ'] = 'ের',
	['জ'] = 'ের',
	['ঝ'] = 'ের',
	['ঞ'] = 'ের',
	['ট'] = 'ের',
	['ঠ'] = 'ের',
	['ড'] = 'ের',
	['ঢ'] = 'ের',
	['ণ'] = 'ের',
	['ত'] = 'ের',
	['থ'] = 'ের',
	['দ'] = 'ের',
	['ধ'] = 'ের',
	['ন'] = 'ের',
	['প'] = 'ের',
	['ফ'] = 'ের',
	['ব'] = 'ের',
	['ভ'] = 'ের',
	['ম'] = 'ের',
	['য'] = 'ের',
	['র'] = 'ের',
	['ল'] = 'ের',
	['শ'] = 'ের',
	['ষ'] = 'ের',
	['স'] = 'ের',
	['হ'] = 'ের',
	['ড়'] = 'ের',
	['ঢ়'] = 'ের',
	-- নিচের বর্ণটি 'য়'
	['়'] = 'ের',
-- 'য়ের'
--	['অ'] = 'য়ের',
--	['আ'] = 'য়ের',
	['ই'] = 'য়ের',
--	['ঈ'] = 'য়ের',
	['উ'] = 'য়ের',
--	['ঊ'] = 'য়ের',
--	['ঋ'] = 'য়ের',
--	['এ'] = 'য়ের',
--	['ঐ'] = 'য়ের',
	['ও'] = 'য়ের',
--	['ঔ'] = 'ের',
	['ং'] = 'য়ের',
}

local exceptions = {'া', 'ি', 'ী', 'ু', 'ূ', 'ৃ', 'ে', 'ৈ', 'ো', 'ৌ'}

local function fix_text(text)
    if text and text ~= '' then
        local length = mw.ustring.len(text)
        local last = mw.ustring.sub(text, -1)
        local append = appends[last]
        
        if length == 1 or (length == 2 and (append or mw.ustring.find(table.concat(exceptions), last, 1, true))) then
            return text .. 'য়ের'
        elseif append then
            return text .. append
        end
    end
    return text or ''
end

local function fix(frame)
	local args = frame:getParent().args
	return fix_text(args[1])
end

return { fix = fix }