Modulo:ISO 3166/datos

Manipud iti Wikipedia, ti nawaya nga ensiklopedia
Darsen a mapan iti pagdaliasatan Darsen a mapan agbiruk
Dokumentasion ti modulo

Dagiti subpanid iti daytoy a modulo ket aglaon kadagiti kodigo ti ISO 3166 nga inus-usar babaen ti Modulo:ISO 3166. Daytoy a modulo ket saan met a para iti panagtaripato/internal a panagusar ken saan koma a usaren kadagiti artikulo.

Dagiti subpanid

Dagiti reporta ti problema

  • Duplikado a nagan: "000" iti /Nasional (eksakto) (GB-SCT)
  • Duplikado a nagan: "000" iti /Nasional (eksakto) (GB-NIR)
  • Duplikado a nagan: "000" iti /Nasional (eksakto) (GB-EAW)
  • Duplikado a nagan: "Saint-Martin" iti /Nasional (di-eksakto) (MF)
  • Duplikado a nagan: "Saint Martin (French part)" iti /Nasional (di-eksakto) (MF)
  • Duplikado a nagan: "St Martin" iti /Nasional (di-eksakto) (MF)
  • Duplikado a nagan: "St Martin (French part)" iti /Nasional (di-eksakto) (MF)
  • Duplikado a nagan: "000" iti /Nasional (eksakto) (GB-WLS)
  • Duplikado a nagan: "Province of Murcia" iti /ES (di-eksakto) (MU)
  • Duplikado a nagan: "Province of Navarre" iti /ES (di-eksakto) (NA)
  • Duplikado a nagan: "Province of Asturias" iti /ES (di-eksakto) (O)
  • Duplikado a nagan: "Province of Cantabria" iti /ES (di-eksakto) (S)
  • Duplikado a nagan: "La Rioja Province" iti /ES (di-eksakto) (LO)

local p = {}

local data = mw.loadData("Modulo:ISO 3166/datos/Nasional")

function p.list(frame)
--Returns a list of subpages and associated countries
local codes = {}
for alpha2,cdata in pairs(data) do
  codes[#codes+1] = {alpha2,cdata.name}
end
table.sort(codes, function(t1,t2) return t1[1]<t2[1] end)

local out = {"* [[Modulo:ISO 3166/datos/Nasional|Nasional]]"}
for _,cdata in ipairs(codes) do
  out[#out+1] = "* [[Modulo:ISO 3166/datos/"..cdata[1].."|"..cdata[1].." ("..cdata[2]..")]]"
end
return table.concat(out,"\n")

end

function p.subpagetest(frame)
--Returns a table row indicating the existence of data pages (see [[User:SiBr4/sandbox#Data subpage test]])

local function cell(code,d)
  local sdata
  if not data[code] then
    return "" --Unassigned or reserved 3166-1 code
  else
    local sname = "Modulo:ISO 3166/datos/"..code
    if not (d 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

local letter = frame.args[1]
local out = "|-\n!"..letter.."*"
for i = 65, 90 do
  out = out.."\n|"..cell(letter..string.char(i),frame.args[2])
end
return out

end

function p.testall(frame)
--Search across all subpages for problems with names

local strip = require("Modulo:ISO 3166").strip

local function subpage(p)
  return "[[Modulo:ISO 3166/datos/"..p.."|/"..p.."]]"
end
local function testname(names,inames,dnames,page,code,name)
  if name then
  	if type(name)~="string" then
  	  dnames[#dnames+1] = "*Di nanamnama a saan a kuerdas a pateg iti "..subpage(page).." ("..code..")"
  	else
      local sname = strip(name)
      if not names[sname] then
        inames[sname] = name
      else
        dnames[#dnames+1] = "*Duplikado a nagan: \""..name.."\" iti "..subpage(page)
                            ..(names[sname]==name and " (eksakto)" or " (di-eksakto)").." ("..code..")"
      end
    end
  end
  return names, inames, dnames
end
local function testnametable(names,inames,dnames,page,code,tab)
  if tab then
    if type(tab)~="table" then
      dnames[#dnames+1] = "*Di nanamnama a saan a tabla a pateg iti "..subpage(page).." ("..code..")"
    else
      for _,name in pairs(tab) do
        names, inames, dnames = testname(names,inames,dnames,page,code,name)
      end
    end
  end
  return names, inames, dnames
end
local fields = {name=1,isoname=1,isonames=1,displayname=1,isodisplayname=1,isodisplaynames=1,altnames=1,lang=1,defaultlang=1,alpha3=1,numeric=1,nocode=1}
local function testentry(names,dnames,page,code,edata)
  for k,_ in pairs(edata) do
    if not fields[k] then
      dnames[#dnames+1] = "*Di ammo a pagikabilan \""..k.."\" in "..subpage(page).." ("..code..")"
    end
  end
  local inames = {}
  names, inames, dnames = testname(names,inames,dnames,page,code,edata.name)
  names, inames, dnames = testname(names,inames,dnames,page,code,edata.isoname)
  names, inames, dnames = testnametable(names,inames,dnames,page,code,edata.isonames)
  names, inames, dnames = testnametable(names,inames,dnames,page,code,edata.altnames)
  if not edata.nocode then
    names, inames, dnames = testname(names,inames,dnames,page,code,code)
  end
  if page=="Nasional" then
    names, inames, dnames = testname(names,inames,dnames,page,code,edata.alpha3)
    names, inames, dnames = testname(names,inames,dnames,page,code,edata.numeric)
  end
  for k,v in pairs(inames) do names[k]=v end
  return names, dnames
end

local dnames = {}

--ISO 3166-1
local names = {}
for code,cdata in pairs(data) do
  names, dnames = testentry(names,dnames,"Nasional",code,cdata)
end

--ISO 3166-2
for code,_ in pairs(data) do
  names = {}
  local spage = "Modulo:ISO 3166/datos/"..code
  if mw.title.new(spage).exists then
    local sdata = mw.loadData(spage)
    for scode,cdata in pairs(sdata) do
      if type(cdata)=="table" then
        names, dnames = testentry(names,dnames,code,scode,cdata)
      end
    end
  end
end

if #dnames>0 then
  return table.concat(dnames,"\n")
else
  return "Awan"
end

end

return p