Revision as of 15:12, 21 March 2017 by m>Ferret(The necessary templates for these all exist now, removing hardcoded value. Will now work with getalias like other countries.)
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
This module implements the {{Video game release}} template. Please see the template page for usage instructions and tracking categories.
require('Module:No globals')localgetArgs=require('Module:Arguments').getArgslocalcd=require('Module:CountryData')localp={}locallabels={['NA']="[[North America|NA]]",['EU']="[[Europe|EU]]",['EUR']="[[Europe|EU]]",['AU']="[[Australasia|AU]]",['AUS']="[[Australasia|AU]]",['PAL']="[[PAL region|PAL]]",['INT']="[[International version|INT]][[Category:Pages using vgrelease with deprecated parameters]]",['SEA']="[[Southeast Asia|SEA]]",['AS']="[[Asia|AS]]",['SA']="[[South America|SA]]",['OC']="[[Oceania|OC]]",['WW']="<abbr title=\"Worldwide\">WW</abbr>",['?']="<abbr title=\"Unknown\">?</abbr>"}localfunctiongetLocalLabel(alias)locallabel=labels[string.upper(alias)]returnlabelendlocalcountryData={};-- Used to store country data to avoid the need of repeated calls to Module:CountryData. This saves a little time if the same abbreviation appears multiple times in the template.localfunctiongetCountryData(frame,alias)localualias=string.upper(alias)if(countryData[ualias]==nil)thenlocalcdtable=cd.gettable(frame,alias,{})countryData[ualias]=cdtable['alias']endreturncountryData[ualias]endfunctionp.main(frame)localargs=getArgs(frame)localout="<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]~=nilandargs[4]==nil)thenout=out.."<li><span style=\"font-size:95%;\">[["if(args[1]~=nil)thenout=out..args[1]endout=out.."|"if(args[2]~=nil)thenout=out..args[2]endout=out.."]]:</span> "..args[3].."[[Category:Pages using vgrelease with two parameter region]]</li>"-- Old syntax "Blank region" use case, where param 1 is empty, and param 2 is the date.elseif(args[1]==nilandargs[2]~=nil)thenout=out.."<li>"..args[2].."[[Category:Pages using vgrelease without a region]]</li>"-- Normal use cases, region/date pairs in 1/2, 3/4, 5/6, etc.elselocali=1localj=2while(args[i]andargs[j])dolocallabel=getLocalLabel(args[i]);-- Didn't find a local label? Check for country data.if(label==nil)thenlabel=getCountryData(frame,args[i])-- Found something? Build a sitelink with it.if(label~=nil)thenlabel="[["..label.."|"..args[i].."]]"elselabel=args[i]endendout=out.."<li><span style=\"font-size:95%;\">"..label..":</span> "..args[j].."</li>"i=i+2j=j+2endendout=out.."</ul>"-- Check for named parameterslocalparameterMsg="[[Category:Pages using vgrelease with named parameters|_VALUE_]]"if(frame:preprocess("{{REVISIONID}}")=="")then-- Preview?parameterMsg="<div class=\"hatnote\" style=\"color:red\"><strong>Warning:</strong> unknown parameter \"_VALUE_\" (this message is shown only in preview).</div>"endfork,vinpairs(args)doif(type(k)~='number')thenlocalmsg=parameterMsg:gsub('_VALUE_',k)out=out..msgendendreturnoutendreturnp