Module:සිංහල

Wiktionary වෙතින්

--[[

මෙම මොඩියුලය විවිධ භාෂාවන්ගේ පද සිංහලට පෙරළීම සඳහා සහයෝගය දක්වයි.

]]

local p = {}
local m_sinhala = require("Module:sinhala")


--[[
english2sinhala

මෙයට ලබා දෙන ඉංග්‍රීසි වචනයට අදාළ සිංහල වචනය ලබා දෙයි.

භාවිතය:
{{#invoke:සිංහල|english2sinhala|ඉංග්‍රීසි_වචනය|}}
හෝ
{{#invoke:සිංහල|english2sinhala|s=ඉංග්‍රීසි_වචනය}}

පරාමිති
    s: ඉංග්‍රීසි වචනය
]]
function p.english2sinhala( frame )
	local new_args = p._getParameters( frame.args, {'s'} )
	local s = new_args['s'] or ''
	return  m_sinhala.sinhala( s )
end

--[[
english2sinhala_plural

මෙයට ලබා දෙන ඉංග්‍රීසි වචනයට අදාළ සිංහල වචනයේ බහු වචනය ලබා දෙයි.

භාවිතය:
{{#invoke:සිංහල|english2sinhala_plural|ඉංග්‍රීසි_වචනය|}}
හෝ
{{#invoke:සිංහල|english2sinhala_plural|s=ඉංග්‍රීසි_වචනය}}

පරාමිති
    s: ඉංග්‍රීසි වචනය
]]
function p.english2sinhala_plural( frame )
	local new_args = p._getParameters( frame.args, {'s'} )
	local s = new_args['s'] or ''
	return  m_sinhala.sinhala_plural( s )
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

--[[
Helper Function to interpret boolean strings
]]
function p._getBoolean( boolean_str )
	local boolean_value

	if type( boolean_str ) == 'string' then
		boolean_str = boolean_str:lower()
		if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'
				or boolean_str == '' then
			boolean_value = false
		else
			boolean_value = true
		end
	elseif type( boolean_str ) == 'boolean' then
		boolean_value = boolean_str
	else
		error( 'No boolean value found' )
	end
	return boolean_value
end


--[[
Helper function to handle error messages.
]]
function p._error( error_str )
	local frame = mw.getCurrentFrame()
	local error_category = frame.args.error_category or 'සිංහල මොඩියුලයේ අසමත් වන ස්ථාන'
	local ignore_errors = frame.args.ignore_errors or false
	local no_category = frame.args.no_category or false

	if p._getBoolean(ignore_errors) then
		return ''
	end

	local error_str = '<strong class="error">සිංහල මොඩියුලයේ අසමත් වීම: ' .. error_str .. '</strong>'
	if error_category ~= '' and not p._getBoolean( no_category ) then
		error_str = '[[ප්‍රවර්ගය:' .. error_category .. ']]' .. error_str
	end

	return error_str
end

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