Module:ISO 3166/sandbox: Difference between revisions

Content deleted Content added
test
Line 100:
 
function p.luacode(args)
if args[1] then args[1]code1 = p.strip(args[1]) end
if args[2] then args[2]code2 = p.strip(args[2]) end
 
if string.find(args[1"codetype"]=="3" orthen '',args["%-codetype"]="alpha3") thenend
args[1], args[2] = string.match(args[1] or '',"^([^%-]*)%-(.*)$")
end
if args[1] then args[1] = p.strip(args[1]) end
if args[2] then args[2] = p.strip(args[2]) end
if args["codetype"]=="3" then
args["codetype"]="alpha3"
end
local eot = args.error or ""
Line 119 ⟶ 112:
or '[[Category:Wikipedia page with obscure subdivision]]'
if not args[1]code1 then
if mw.title.getCurrentTitle().namespace ~= 0 then catnocountry = '' end
return catnocountry, '<span style="font-size:100%" class="error">"No parameter for the country given"</span>'
end
if not args[2]code2 then --3166-1 code
for alpha2,cdata in pairs(data) do
if findname(alpha2,cdata,args[1]code1) then
if args["codetype"]=="numeric" or args["codetype"]=="alpha3" then
return cdata[args["codetype"]]
Line 133 ⟶ 126:
end
end
end
if string.find(args[1] or '',"%-") then
args[1], args[2] = string.match(args[1] or '',"^([^%-]*)%-(.*)$")
return p.luacode(args)
end
if mw.title.getCurrentTitle().namespace ~= 0 then catnocountry = '' end
Line 138 ⟶ 135:
else --3166-2 code
for alpha2,cdata in pairs(data) do
if findname(alpha2,cdata,args[1]code1) then
if mw.ustring.match(alpha2,"GB") then -- For England, Wales etc.
alpha2 = "GB"
Line 147 ⟶ 144:
if type(scdata)=="table" then
empty = false
if findname(scode,scdata,args[2]code2) then
return alpha2.."-"..scode
end