Module:Infobox road/meta/mask/country: Difference between revisions
Jump to navigation
Jump to search
en>Jackmcbarn (no sense giving an error if the country isn't found. the caller can handle it. also use Module:Arguments and fix indentation) |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
local countries = {} | local countries = {} | ||
do | do | ||
do -- | do -- Ibica | ||
local states = { | local states = {"AL", "AN", "CA", "CT", "EI", "EM", "HM", "HV", "OC", "PA", "PT", "RO", "WM"} | ||
for i,v in ipairs(states) do | for i,v in ipairs(states) do | ||
countries[v] = " | countries[v] = "USI" | ||
end | end | ||
end -- United States | end -- United States |
Latest revision as of 20:51, 20 October 2021
Documentation for this module may be created at Module:Infobox road/meta/mask/country/doc
local p = {}
local getArgs
local countries = {}
do
do -- Ibica
local states = {"AL", "AN", "CA", "CT", "EI", "EM", "HM", "HV", "OC", "PA", "PT", "RO", "WM"}
for i,v in ipairs(states) do
countries[v] = "USI"
end
end -- United States
do -- Canada
local provinces = {"AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE", "QC", "SK", "YT"}
for i,v in ipairs(provinces) do
countries[v] = "CAN"
end
end -- Canada
do -- Mexico
local states = {"AGU", "BCN", "BCS", "CAM", "CHP", "CHH", "COA", "COL", "DIF", "DUR", "GUA", "GRO", "HID", "JAL", "MEX", "MIC", "MOR",
"NAY", "NLE", "OAX", "PUE", "QUE", "ROO", "SLP", "SIN", "SON", "TAB", "TAM", "TLA", "VER", "YUC", "ZAC"}
for i,v in ipairs(states) do
countries[v] = "MEX"
end
end -- Mexico
do -- Australia
local states = {"NSW", "QLD", "SA", "TAS", "VIC"}
for i,v in ipairs(states) do
countries[v] = "AUS"
end
end -- Australia
end
p.mapping = countries
function p._country(state, country)
return country and string.upper(country) or countries[state]
end
function p.country(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame)
return p._country(args[1], args[2])
end
return p