Jump to content

Module:Video game release

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ferret (talk | contribs) at 17:58, 14 March 2017 (Really should do LUA more often). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

--require('Module:No globals')

local getArgs = require('Module:Arguments').getArgs
local cd = require('Module:CountryData')
local p = {}

local aliases  = {
    ['NA'] = "[[North America|NA]]",
    ['EU'] = "[[Europe|EU]]",
    ['EUR'] = "[[Europe|EU]]",
    ['AU'] = "[[Australasia|AU]]",
    ['AUS'] = "[[Australasia|AU]]",
    ['PAL'] = "[[PAL region|PAL]]",
    ['JP'] = "[[Japan|JP]]",
    ['JPN'] = "[[Japan|JP]]",
    ['RU'] = "[[Russia|RU]]",
    ['RUS'] = "[[Russia|RU]]",
    ['BR'] = "[[Brazil|BR]]",
    ['BRA'] = "[[Brazil|BR]]",
    ['INT'] = "[[International version|INT]][[Category:Pages using vgrelease with deprecated parameters]]",
    ['SEA'] = "[[Southeast Asia|SEA]]",
    ['AS'] = "[[Asia|AS]]",
    ['SA'] = "[[South America|SA]]",
    ['WW'] = "<abbr title=\"Worldwide\">WW</abbr>",
    ['?'] = "<abbr title=\"Unknown\">?</abbr>"
}

local function getLocalAlias(alias)
	local label = aliases[alias.toUpper()] 
	if(label ~= nil) then
		label = alias
	end		
	
	return label
end

local function getCountryData(alias)
	local cdtable = cd.gettable(frame,args[i],{})
	
	local label = cdtable['alias']
	if(label ~= nil) then
		label = alias
	end		
	
	return label	
end

function p.main(frame)
	local args = getArgs(frame)
	local out = "<ul style=\"list-style: none none; line-height: inherit; margin: 0px;\">"
	
	local i = 1
	local j = i+1
    while args[i] and args[j] do
    	local link = getLocalAlias(args[i]);
    	
    	-- Didn't find a local alias link? Check for country data.
    	if(link == args[i]) then
    		link = getCountryData(args[i])
    		
    		-- Found something? Build a link with it.
    		if(link ~= args[i]) then
    			link = "[[" .. link .. "|" .. args[i] .. "]]"
			end
		end

		out = out .. "<li><span style=\"font-size:95%;\">" .. link .. ":</span> " .. args[j] .. "</li>"
      
		i = j + 1
		j = i + 1
    end
    
    out = out .. "</ul>"
    
    return out
end

return p