模組:Flag/sandbox

local p = {}
local yesno = require('Module:Yesno')
local mError = require('Module:Error')
local mCountryData = require('Module:CountryData')

local gFrame = mw.getCurrentFrame()

local function renderError(msg)
	return mError.error{"[[Module:Flag]]錯誤:" .. msg}
end

function p._country_data_callback(args, options)
	local file
	
	if options.checkVarient then
		file =
			args.variant and args["flag alias-" .. args.variant] or
			args.altvar and args["flag alias-" .. args.altvar] or
			args["flag alias"]
	else
		file = args["flag alias"]
	end
	if not file then
		return renderError("參數 <code>flag alias</code> 為空。")
	end
	local success, file = pcall(mw.title.new, file, 'Media')
	if not success or not file then
		return renderError("flag alias <code>" .. file .. "</code> 無效。")
	elseif not file.exists then
		return renderError("檔案 [[" .. file .. "]] 不存在。")
	end
end

return p