local p =
local roadDataModule = require('Module:Road data')local format = mw.ustring.formatlocal frame = mw.getCurrentFramelocal getArgs = require('Module:Arguments').getArgs
local function country(args) local state = args.state or args.province local country local countryModule = mw.loadData("Module:Road data/countrymask") local country = args.country or countryModule[state] return countryend
local function state(args) local state = args.state or args.province local country = country(args) return frame:expandTemplate end
local function state2(args) local state = args.state2 or args.province2 local country = country(args) return frame:expandTemplate end
local function spain(args) local province = args.province or args.community local communities = local comm = communities[province] local data = frame:expandTemplate return data end
local function constituent(args) local loc = country(args) if loc
local function location(args) local infobox_args = infobox_args['title'] = 'Location' infobox_args['bodystyle'] = 'display:inline-table;' infobox_args['child'] = 'yes' infobox_args['decat'] = 'yes'
------------- EUROPE & ASIA -------------- if country(args)
"ASIA" then infobox_args['label1'] = 'Countries' infobox_args['data1'] = args.countries ------------- ÅLAND -------------- elseif country(args)
------------- AUSTRALIA -------------- elseif country(args)
"NT" or args.state
"JBT" then infobox_args['label2'] = 'Territory' else infobox_args['label2'] = 'State' end infobox_args['data2'] = frame:expandTemplate else infobox_args['label2'] = 'States' infobox_args['data2'] = args.states end infobox_args['label3'], infobox_args['data3'] = lga(args) infobox_args['label4'], infobox_args['data4'] = locations(args) ------------- BRAZIL -------------- elseif country(args)
"DF" then infobox_args['label2'] = 'Federal district' else infobox_args['label2'] = 'State' end infobox_args['data2'] = frame:expandTemplate else infobox_args['label2'] = 'States' infobox_args['data2'] = args.states end ------------- CANADA -------------- elseif country(args)
"YK" or args.province
"NU" then infobox_args['label2'] = 'Territory' else infobox_args['label2'] = 'Province' end infobox_args['data2'] = frame:expandTemplate else infobox_args['label2'] = 'Provinces' infobox_args['data2'] = args.provinces end if args.province
'BC' then infobox_args['label3'] = "Regional districts" infobox_args['data3'] = args.districts or args.rural_municipalities elseif args.province
'SK' then infobox_args['label3'] = "Rural municipalities" infobox_args['data3'] = args.rural_municipalities elseif args.province
'PE' then infobox_args['label3'] = "Counties" infobox_args['data3'] = args.counties infobox_args['label4'] = "Parishes" infobox_args['data4'] = args.parishes infobox_args['label5'] = "Communities" infobox_args['data5'] = args.communities elseif args.province
'ON' then infobox_args['label3'] = "Municipalities" infobox_args['data3'] = args.rural_municipalities infobox_args['label4'] = "Counties" infobox_args['data4'] = args.counties infobox_args['label5'] = "Regions" infobox_args['data5'] = args.regions infobox_args['label6'] = "Districts" infobox_args['data6'] = args.districts infobox_args['label7'] = "Divisions" infobox_args['data7'] = args.divisions elseif args.province
'NT' or args.province
------------- CHINA -------------- elseif country(args)
"HKG" or country(args)
"HKG" then infobox_args['label2'] = 'Special administrative region' infobox_args['data2'] = "Hong Kong" infobox_args['label3'] = 'Districts' infobox_args['data3'] = args.districts elseif country(args)
"FRA" or country(args)
"GLP" or country(args)
"MYT" or country(args)
"GUF" then infobox_args['label2'] = 'Overseas region' infobox_args['data2'] = "French Guiana" infobox_args['label3'] = 'Department' infobox_args['data3'] = "Guyane" elseif country(args)
"MTQ" then infobox_args['label2'] = 'Overseas region and department' infobox_args['data2'] = "Martinique" elseif country(args)
"REU" then infobox_args['label2'] = 'Overseas region' infobox_args['data2'] = "Réunion" infobox_args['label3'] = 'Department' infobox_args['data3'] = "La Réunion" else infobox_args['label2'] = 'Regions' infobox_args['data2'] = args.regions infobox_args['label3'] = 'Departments' infobox_args['data3'] = args.departments end ------------ GEORGIA ------------- elseif country(args)
"IND" then infobox_args['label1'] = 'Country' infobox_args['data1'] = "India" infobox_args['label4'] = 'Districts' infobox_args['data4'] = args.districts if args.state then if args.state
'CH' or args.state
'DL' or args.state
'LA' or args.state
'PY' then infobox_args['label2'] = 'Union territory' else infobox_args['label2'] = 'State' end infobox_args['data2'] = frame:expandTemplate else infobox_args['label2'] = 'States' infobox_args['data2'] = args.states infobox_args['label3'] = 'Union territories' infobox_args['data3'] = args.territories end ------------- MEXICO -------------- elseif country(args)
"CMX" then infobox_args['label2'] = 'Autonomous city' else infobox_args['label2'] = 'State' end if args.state
"HID" then infobox_args['data2'] = 'Hidalgo' elseif args.state
------------- NETHERLANDS -------------- elseif country(args)
"ABW" or country(args)
"SXM"then infobox_args['label1'] = 'Country' infobox_args['data1'] = "Kingdom of the Netherlands" infobox_args['label2'], infobox_args['data2'] = constituent(args) if country(args)
"RUS" then infobox_args['label1'] = 'Country' infobox_args['data1'] = "Russia" infobox_args['label2'] = 'Oblasts' infobox_args['data2'] = args.oblasts infobox_args['label3'] = 'Republics' infobox_args['data3'] = args.republics infobox_args['label4'] = 'Autonomous okrugs' infobox_args['data4'] = args.okrugs infobox_args['label5'] = 'Krais' infobox_args['data5'] = args.krais infobox_args['label6'] = 'Federal cities' infobox_args['data6'] = args.federal_cities ------------- SPAIN -------------- elseif country(args)
"O" or province
"PM" or province
"M" or province
"NA" then return nil else infobox_args['label3'] = 'Province' infobox_args['data3'] = frame:expandTemplate end elseif args.community then infobox_args['label2'] = 'Autonomous
community' infobox_args['data2'] = frame:expandTemplate infobox_args['label3'] = 'Provinces' infobox_args['data3'] = args.provinces else infobox_args['label2'] = 'Autonomous
communities' infobox_args['data2'] = args.communities infobox_args['label3'] = 'Provinces' infobox_args['data3'] = args.provinces end
------------- UNITED KINGDOM -------------- elseif country(args)
"ENG" or country(args)
"SCT" or country(args)
"GGY" or country(args)
"JEY" or country(args)
"BMU" or country(args)
"VGB" or country(args)
"FLK" or country(args)
"MSR" or country(args)
"SHN" or country(args)
"TCA" then
infobox_args['label1'] = 'Country' infobox_args['data1'] = "United Kingdom" infobox_args['label2'], infobox_args['data2'] = constituent(args) if country(args) ~= "ENG" then infobox_args['label5'] = 'Counties' infobox_args['data5'] = args.counties end
if country(args)
"NIR" then infobox_args['label3'] = 'Districts' infobox_args['data3'] = args.districts elseif country(args)
"WLS" then infobox_args['label3'] = 'Counties' infobox_args['data3'] = args.counties infobox_args['label4'] = 'County boroughs' infobox_args['data4'] = args.boroughs elseif country(args)
"JEY" or country(args)
"MSR" then infobox_args['label3'] = 'Parishes' infobox_args['data3'] = args.parishes elseif country(args)
"AIA" or country(args)
"CYM" or country(args)
"SHN" then infobox_args['label3'] = 'Island' infobox_args['data3'] = args.island end
------------- UNITED STATES -------------- elseif country(args)
'LA' then county = 'Parish' elseif state
'PR' then county = 'Municipality' else county = 'County' end return string.format("%s", countyName, county, stateName, countyName) end
if args.state2 then infobox_args['label2'] = 'States' infobox_args['data2'] = frame:expandTemplate .. ", " .. frame:expandTemplate elseif args.state then if args.state
"GU" or args.state
"PR" or args.state
"DC" then infobox_args['label2'] = 'Federal district' else infobox_args['label2'] = 'State' end if args.state
"WA" then infobox_args['data2'] = 'Washington' elseif args.state
"GBR" or country(args)
"NIR" or country(args)
"WLS" or country(args)
"IMN" or country(args)
"AIA" or country(args)
"IOT" or country(args)
"CYM" or country(args)
"GIB" or country(args)
"PCN" or country(args)
"SGS" or country(args)
return frame:expandTemplate end
local function params(args)
if country(args) or args.areas or args.borough or args.boroughs or args.cantons or args.cities or args.communes or args.communities or args.counties or args.countries or args.county or args.departments or args.destinations or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories or args.towns or args.villages then return true else return false endend
function p.location(frame) local args = getArgs(frame) if params(args)
return p