Module:ISO 3166: Difference between revisions

Fixed catergories
(Added error codes)
(Fixed catergories)
Line 8:
local getArgs = require("Module:Arguments").getArgs
local data = mw.loadData("Module:ISO 3166/data/National")
 
--[[----------C E R R O R----------]]---- Creates error messages
 
local function cerror(eot,errortext,inputtext)
if eot=="empty" or eot=="" then
return nil
elseif eot=="input" then
return inputtext
else
return mw.html.create("span"):addClass("error"):wikitext("Error in [[Module:ISO 3166]]: "..errortext)
end
end
 
--[[----------F I N D N A M E----------]]---- Finds the name in the database
Line 130 ⟶ 118:
then
if code2=="" then
return cerror(eot,"Invalid ISO 3166-1 code "..code1,orig),'[[Category:Wikipedia page with obscure country]]'
else
return cerror(eot,"Invalid ISO 3166-2 code "..code1.."-"..code2,orig),'[[Category:Wikipedia page with obscure country or subdivision]]'
end
end
Line 144 ⟶ 132:
or (data[code1]["displayname"] or data[code1]["name"])
else
return cerror(eot,"Unknown ISO 3166-1 code "..code1,orig),'[[Category:Wikipedia page with obscure country]]'
end
else
Line 152 ⟶ 140:
sdata = mw.loadData("Module:ISO 3166/data/"..code1)
else
return cerror(eot,"Unknown ISO 3166-1 code "..code1,orig),'[[Category:Wikipedia page with obscure country]]'
end
if sdata[code2] then
Line 160 ⟶ 148:
else
for _,_ in pairs(sdata) do
return cerror(eot,"Unknown'[[Category:Wikipedia ISOpage 3166-2with codeobscure "..code1.."-"..code2,orig)country]]'
end
return cerror(eot,"No'[[Category:Wikipedia subdivisionpage codeswith forobscure "..data[code1country]["name"],orig)'
end
end
Line 175 ⟶ 163:
end
end
return cerror(eot,"Unknown ISO 3166-1 code "..code1,orig),'[[Category:Wikipedia page with obscure country]]'
end
Line 213 ⟶ 201:
end
end
return cerror(eot,"Unknown country name "..args[1],args[1]),'[[Category:Wikipedia page with obscure country]]'
else
--3166-2 code
Line 229 ⟶ 217:
end
if empty then
return cerror(eot,"No subdivision codes for "..args[1],args[2]),'[[Category:Wikipedia page with obscure subdivision]]'
else
return cerror(eot,"Unknown subdivision name "..args[2],args[2]),'[[Category:Wikipedia page with obscure subdivision]]'
end
end
end
return cerror(eot,"Unknown country name "..args[1],args[2]),'[[Category:Wikipedia page with obscure country]]'
end
Anonymous user