মডিউল:এর/খেলাঘর২

উইকিপিডিয়া, মুক্ত বিশ্বকোষ থেকে
মডিউল নথি[তৈরি করুন]
local p = {}

local getArgs = require('Module:Arguments').getArgs

local vowels = {'া', 'ি', 'ী', 'ু', 'ূ', 'ৃ', 'ে', 'ৈ', 'ো', 'ৌ'}
local consonants = {'ক', 'খ', 'গ', 'ঘ', 'ঙ', 'চ', 'ছ', 'জ', 'ঝ', 'ঞ', 'ট', 'ঠ', 'ড', 'ঢ', 'ণ', 'ত', 'থ', 'দ', 'ধ', 'ন', 'প', 'ফ', 'ব', 'ভ', 'ম', 'য', 'র', 'ল', 'শ', 'ষ', 'স', 'হ', 'ড়', 'ঢ়', '়'}
local fullvowels = {'ই', 'উ', 'ও', 'ং'}



function fix_text(text)
	if text and text ~= '' then
		local last = mw.ustring.sub(text, -1)
		for n, vowel in ipairs(vowels) do 
			if last == vowel then
				local append = 'র'
				break
			end
		end
		for n, consonant in ipairs(consonants) do 
			if last == consonant then
				local append = 'ের'
				break
			end
		end
		for n, fvowel in ipairs(fullvowels) do 
			if last == fvowel then
				local append = 'য়ের'
				break
			end
		end
		if append then
			return text .. append
		end
	end
	return text or ''
end

function p._fix(frame)
	local args = getArgs(frame)
	return fix_text(args[1])
end

return p