Jump to content

Module:ISO 3166/data

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SiBr4 (talk | contribs) at 20:22, 9 February 2016. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.subpagetest(frame)

local data = mw.loadData("Module:ISO 3166/data/National")

local code = frame.args[1]

local sdata
if not data[code] then
  return "" --Unassigned or reserved 3166-1 code
else
  local sname = "Module:ISO 3166/data/"..code
  if not (frame.args[2]=="1" or mw.title.new(sname).exists) then
    return "title=\""..data[code].name.."\" style=\"background:#fee;\"|[["..sname.."|-]]" --Data subpage doesn't exist
  else
    sdata = mw.loadData(sname)
  end
end
for _,_ in pairs(sdata) do
  return "title=\""..data[code].name.."\" style=\"background:#efe;\"|n" --Non-empty 3166-2 entry
end
return "title=\""..data[code].name.."\" style=\"background:#eef;\"|e" --Empty 3166-2 entry

end

return p