Module:Leftright

د ويکيپېډيا، وړیا پوهنغونډ له خوا

لاسوند لپاره ددې موډيول کېدای سی په Module:Leftright/لاسوند کي وي

-- fork of "Module:Yesno"
-- Implements {{ښي کيڼ}}
-- Converts local or abbreviated forms of "left", "right" and "center"
-- to a value usable for HTML attributes such as "align" or "float"

require( 'strict' )

local p = {}

function p.leftRight(input, default)
	local out
	input = type(input) == 'string' and mw.ustring.lower(input) or input
	if input == nil then
		out = nil
	elseif input == 'ښي'
		or input == 'ښ'
		or input == 'right'
		or input == 'r'
	then
		out = 'right'
	elseif input == 'کیڼ'
		or input == 'ک'
		or input == 'left'
		or input == 'l'
	then
		out = 'left'
	elseif input == 'مرکز'
		or input == 'م'
		or input == 'center'
		or input == 'centre'
		or input == 'c'
	then
		out = 'center'
	elseif input == 'ښي څخه کیڼ'
		or input == 'rtl'
	then
		out = 'rtl'
	elseif input == 'کیڼ نه ښي'
		or input == 'ltr'
	then
		out = 'ltr'
	else
		out = default
	end
	return out
end

-- remove whitespaces from beginning and end of args
local function valueFunc(key, val)
	if type(val) == 'string' then
		val = mw.ustring.match(val, '^%s*(.-)%s*$')
		if val == '' then
			return nil
		end
	end
	return val
end

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {wrappers = 'کينډۍ:ښي کيڼ', valueFunc = valueFunc})
	return p.leftRight(args[1], (args[2] or args['خپلکارې بڼه']) or 'left')
end

return p