-- @brief
--  Backend for {{Príklad}}.
-- 
-- @details
--  Generates usage example item.
-- 
-- @author
--  [[meta:User:Danny B.]]
local _module = {}
----------------------------------------


local Error = require( "Module:Error" )


-- @brief
--  Write the usage example item.
-- 
-- @param
--  frame The current frame object
-- 
-- @return
--  Preprocessed wikitext
function _module.print( frame )
	
	local output = ""
	local parentFrame = frame:getParent()
	local templateArgs = parentFrame.args
	local errorData = { template = "Príklad" }
	
	local lang = mw.text.trim( templateArgs[1] or "" )
	local example = mw.text.trim( templateArgs[2] or "" )
	local translation = mw.text.trim( templateArgs[3] or "" )
	
	
	if lang == "" then
		errorData.missingValue = { paramName = 1, paramDesc = "kód jazyka" }
		output = output .. Error.getText( errorData )
	end
	
	if example == "" then
		errorData.missingValue = { paramName = 2, paramDesc = "príklad" }
		output = output .. Error.getText( errorData )
	end
	
	if output == "" then
		if lang ~= "sk" then
			lang = "lang=\"" .. lang .. "\" xml:lang=\"" .. lang .. "\" "
		else
			lang = ""
		end
		output = output .. "<span " .. lang .. "class=\"usageexample\">" .. example .. "</span>"
		if translation ~= "" then
			output = output .. " – " .. translation
		end
	end
	
	output = frame:preprocess( output )
	
	return output
	
end


----------------------------------------
return _module