Module:රට

විකිපීඩියා වෙතින්

local p = {}

local yesno = require('Module:Yesno')
local data = mw.loadData("Module:රට/දත්ත")

function p.name2code( frame )
	local new_args = p._getParameters( frame.args, {'s'} )
	local s = new_args['s'] or ''

	return data[s]
end

function p.code2name( frame )
	local new_args = p._getParameters( frame.args, {'s', 'of'} )
	local s = new_args['s'] or ''
	local of = new_args['of'] or ''
	local ret = ''

	if yesno(of) then
		ret = frame:expandTemplate{ title = 'ඔෆ් සඳහා උපසර්ගය', args = { data[s] } }
	else
		ret = data[s]
	end

	return ret
end

--[[
පැරාමිති වෙන්කර ගැනීම සඳහා වන සහාය ක්‍රියාවලිය.
]]
function p._getParameters( frame_args, arg_list )
	local new_args = {}
	local index = 1
	local value

	for _, arg in ipairs( arg_list ) do
		value = frame_args[arg]
		if value == nil then
			value = frame_args[index]
			index = index + 1
		end
		new_args[arg] = value
	end

	return new_args
end

return p
"https://si.wikipedia.org/w/index.php?title=Module:රට&oldid=589816" වෙතින් සම්ප්‍රවේශනය කෙරිණි