Module:Wq/si/සිංහල

භාවිතය

edit

<includeonly></includeonly>


p = {}

function p.english2sinhala( frame )
	local data = mw.loadData('Module:Wq/si/සිංහල/දත්ත').data

	local args = p._getParameters(frame.args, {'word'})
	local word = args.word

	for k, v in pairs( data ) do
		-- process each key-value pair
		if v.en == word then
			return v.si
		end
	end
	return word
end

function p.sinhala2english( frame )
	local data = mw.loadData('Module:Wq/si/සිංහල/දත්ත').data

	local args = p._getParameters(frame.args, {'word'})
	local word = args.word

	for k, v in pairs( data ) do
		-- process each key-value pair
		if v.si == word then
			return v.en
		end
	end
	return word
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