--require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local cd = require('Module:CountryData')
local p = {}
local links = {
['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 getLocalLink(alias)
local link = links[string.upper(alias)]
return link
end
local function getCountryData(frame, alias)
local cdtable = cd.gettable(frame,alias,{})
return cdtable['alias']
end
function p.main(frame)
local args = getArgs(frame)
local out = "<ul style=\"list-style: none none; line-height: inherit; margin: 0px;\">"
-- Old syntax "Two parameter region" use case, where param 1 is an article, param 2 is a label, and param 3 is the date. We assume this case if argument 4 is nil.
if args[3] ~= nil and args[4] == nil then
out = out .. "<li><span style=\"font-size:95%;\">[[" .. args[1] .. "|" .. args[2] .. "]]:</span> " .. args[3] .. "</li>"
--[[Category:Pages using vgrelease with two parameter region]]
-- Old syntax "Blank region" use case, where param 1 is empty, and param 2 is the date.
elseif args[1] == nil and args[2] ~= nil then
out = out .. "<li>" .. args[2] .. "</li>"
--[[Category:Pages using vgrelease without a region]]
-- Normal use cases, region/date pairs in 1/2, 3/4, 5/6, etc.
else
local i = 1
local j = i+1
while args[i] and args[j] do
local link = getLocalLink(args[i]);
-- Didn't find a local link? Check for country data.
if(link == nil) then
link = getCountryData(frame, args[i])
-- Found something? Build a sitelink with it.
if(link ~= nil) then
link = "[[" .. link .. "|" .. args[i] .. "]]"
else
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
end
out = out .. "</ul>"
return out
end
return p