มอดูล:Flag

local margs = require('มอดูล:Arguments')
local function _main(frame, name, mode)
	local categories = {
		'Flagicon' = 'หมวดหมู่:Flagicons ขาดแม่แบบข้อมูลประเทศ',
		'Flag decoration' = 'หมวดหมู่:Flag decoration ขาดแม่แบบข้อมูลประเทศ',
	}
local yesno = require('มอดูล:Yesno')
	--Get input arguments
	local args = margs.getArgs(frame, {
		frameOnly = ((frame.args.frameonly or ) ~= ), valueFunc =
			function(key,value)
				if value then
					value = mw.text.trim(value)
					--Change empty string to nil for all args except 'image' and 'border'
					if key=="image" or key=="border" or value~="" then
						return value
					end
				end
				return nil
			end
	} )
	
	local preftext, sufftext = "", ""
	
	if name == 'Flag+link' then
		args.pref = args1
	elseif name == 'Flagathlete' then
		args.preftext = args1
		args2 = args.code or args2 or ""
		args.variant = args.variant or args3
	elseif name == 'Flagmedalist' then
		preftext = (args1 or "") .. ""
		args2 = args.code or args2 or ""
		args.variant = args.variant or args3
	elseif name == 'Flaglink' then
		args.suff = args2
		args2 = args1 or ""
		args.variant = args.variant or args3
	else
		sports = {fb = 'fb', 'fb-rt' = 'fb', fbicon = 'fb', ru = 'ru'}
		if sportsname then
			args.avar = sportsname
			if name == 'fb' and yesno(args.align) == true then
				args.align='c'
			end
		elseif name == "Flagteam" and (args.code or args1) then
			sufftext = ' ('..(args.code or args1)..')'
		end
		args.variant = args.variant or args2
		args2 = args1 or ""
	end
	args1 = mode .. (args.opts or )
	args.missingcategory = categoriesname
	args.noredlink = args.noredlink or 'notext'
	if args.placeholder and yesno(args.placeholder) ~= true then
		args1 = args1 .. 'o'
	end
	if mw.title.getCurrentTitle().namespace == 0 then
		local unknown = 
	else
		local unknown = 
	end
	
	check = 
	
	if name == 'Flagicon' then
		local opts = {
unknown=unknown,
preview='หน้านี้ใช้ แม่แบบ:' .. name .. ' ที่มีพารามิเตอร์ที่ไม่รู้จัก "_VALUE_"',
ignoreblank='y',
'1','2','variant','image','size','sz','border','align','al','width',
'w','alt','ilink','noredlink','missingcategory','name','clink','link',
'pref','suff','plink','the','section','altvar','avar','age','nalign',
'nal','text','nodata','opts','placeholder','getParent','frameonly'
		}
		check = require('มอดูล:Check for unknown parameters')._check(opts,args)
	end
	return preftext .. require('มอดูล:Flagg').luaMain(frame,args) .. sufftext .. check
end
local p = {
	       = function (frame) return _main(frame, 'Flag',            'unc'   ) end,
	decoration = function (frame) return _main(frame, 'Flag decoration', 'uxx'   ) end,
	icon       = function (frame) return _main(frame, 'Flagicon',       'cxxl'  ) end,
	link       = function (frame) return _main(frame, 'Flaglink',       'unpe'  ) end,
	'+link'  = function (frame) return _main(frame, 'Flag+link',       'unpefo') end,
	country    = function (frame) return _main(frame, 'Flagcountry',    'unce'  ) end,
	team       = function (frame) return _main(frame, 'Flagteam',       'unce'  ) end,
	athlete    = function (frame) return _main(frame, 'Flagathlete',    'unape' ) end,
	medalist   = function (frame) return _main(frame, 'Flagmedalist',   'unce'  ) end,
	fb         = function (frame) return _main(frame, 'fb',              'unpe'  ) end,
	'fb-rt'  = function (frame) return _main(frame, 'fb-rt',           'unpre' ) end,
	fbicon     = function (frame) return _main(frame, 'fbicon',          'pxxl'  ) end,
	ru         = function (frame) return _main(frame, 'ru',              'unpe'  ) end,
	IOC        = function (frame) return require('มอดูล:Country_alias').flagIOC(frame:newChild{ title = 'แม่แบบ:FlagIOC' }) end,
	IOC2       = function (frame) return require('มอดูล:Country_alias').flagXYZ(frame:newChild{ title = 'แม่แบบ:FlagIOC2', args = {name = margs.getArgs(frame).name or , type = 'name'} }) end,
	IOCathlete = function (frame) return require('มอดูล:Country_alias').flagXYZ(frame:newChild{ title = 'แม่แบบ:FlagIOCathlete', args = {type = 'athlete-O'} }) end,
}
p'deco' = p.decoration
p'IOC2' = p.IOC2
p'IOCathlete' = p.IOCathlete
return p