Module:Country

From SMITE Esports Wiki
Jump to: navigation, search

To edit the documentation or categories for this module, click here.


local util_args = require('Module:ArgsUtil')
local LOOKUP = mw.loadData('Module:Countrynames')

local p = {}

function p.main(frame)
	-- this should only be invoked, never called directly from another module
	local args = util_args.merge(true)
	
	if not args[1] then
		return ''
	end
	local style = args[2] or 'name'
	
	return p[style](args[1])
end


function p.default(str)
	-- deprecated but leaving here for compatibility
	local vars = util_args.lookupVars(str, LOOKUP)
	return vars.name
end

function p.name(str)
	local vars = util_args.lookupVars(str, LOOKUP)
	return vars.name
end

function p.rightlong(str)
	-- text to the right of the image
	local vars = util_args.lookupVars(str, LOOKUP)
	if vars.flag then
		return ('[[File:%s.png|%s|link=]] %s'):format(
			vars.flag,
			vars.name,
			vars.name
		)
	end
	return vars.name
end

function p.localization(str)
	local vars = util_args.lookupVars(str, LOOKUP)
	return vars.adjective
end

function p.onlyimage(str)
	local vars = util_args.lookupVars(str, LOOKUP)
	return vars.flag and string.format(
		'[[File:%s.png|%s|link=]]',
		vars.flag,
		vars.name
	) or ''
end

function p.namethe(str)
	local vars = util_args.lookupVars(str, LOOKUP, DEFAULT)
	return (vars.the and 'the ' or '') .. (vars.name or '')
end

return p