Module:ISO 3166: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Added support for England Wales etc.)
No edit summary
Line 9: Line 9:
local data = mw.loadData("Module:ISO 3166/data/National/sandbox")
local data = mw.loadData("Module:ISO 3166/data/National/sandbox")


--[[----------F I N D N A M E----------]]---- Finds the name in the database
--[[----------F I N D N A M E----------]]-- -- Finds the name in the database


local function findname(code,cdata,qry)
local function findname(code,cdata,qry)
Line 33: Line 33:
end
end


--[[----------I S O N A M E----------]]---- Find the ISO name of a country/region
--[[----------I S O N A M E----------]]-- -- Find the ISO name of a country/region


function isoname(data,code,lang)
function isoname(data,code,lang)
Line 51: Line 51:
end
end


--[[----------S T R I P----------]]---- Removes junk from the input
--[[----------S T R I P----------]]-- -- Removes junk from the input


function p.strip(text)
function p.strip(text)
Line 72: Line 72:
text = match
text = match
end
end
text = mw.ustring.upper(text) --Case insensitivity
text = mw.ustring.upper(text) --Case insensitivity
text = string.gsub(text,"^THE ","") --Remove definite article
text = string.gsub(text,"^THE ","") --Remove definite article
text = string.gsub(text,"[%s%-%,%.%(%)%/%\']","") --Remove spacing and punctuation
text = string.gsub(text,"[%s%-%,%.%(%)%/%\']","") --Remove spacing and punctuation
local accents = {["À"]="A",["Á"]="A",["Â"]="A",["Ã"]="A",["Ä"]="A",["Å"]="A",["Ç"]="C",["È"]="E",["É"]="E",
local accents = {["À"]="A",["Á"]="A",["Â"]="A",["Ã"]="A",["Ä"]="A",["Å"]="A",["Ç"]="C",["È"]="E",["É"]="E",
["Ê"]="E",["Ë"]="E",["Ì"]="I",["Í"]="I",["Î"]="I",["Ï"]="I",["Ñ"]="N",["Ò"]="O",["Ó"]="O",
["Ê"]="E",["Ë"]="E",["Ì"]="I",["Í"]="I",["Î"]="I",["Ï"]="I",["Ñ"]="N",["Ò"]="O",["Ó"]="O",
Line 82: Line 82:
end
end


--[[----------P . C A L L S T R I P ---------]]---- Calls P.strip but using Module:Arguments
--[[----------P . C A L L S T R I P ---------]]-- -- Calls P.strip but using Module:Arguments


function p.callstrip(frame)
function p.callstrip(frame)
Line 92: Line 92:
end
end


--[[----------P . L U A C O D E---------]]---- Makes the ISO code of a country
--[[----------P . L U A C O D E---------]]-- -- Makes the ISO code of a country


function p.luacode(args)
function p.luacode(args)
Line 148: Line 148:
end
end


--[[----------P . C O D E---------]]---- Calls P.Luacode but using Module:Arguments
--[[----------P . C O D E---------]]-- -- Calls P.Luacode but using Module:Arguments


function p.code(frame)
function p.code(frame)
Line 156: Line 156:
end
end


--[[----------P . N U M E R I C---------]]---- Calls P.Luacode but using Module:Arguments and setting it to output a numeric value
--[[----------P . N U M E R I C---------]]-- -- Calls P.Luacode but using Module:Arguments and setting it to output a numeric value


function p.numeric(frame)
function p.numeric(frame)
Line 168: Line 168:
end
end
--[[----------P . L U A N A M E---------]]---- Makes the ISO/common name of a country
--[[----------P . L U A N A M E---------]]-- -- Makes the ISO/common name of a country
function p.luaname(args)
function p.luaname(args)
Line 207: Line 207:
end
end


--[[----------P . N A M E---------]]---- Calls P.Luaname but using Module:Arguments
--[[----------P . N A M E---------]]-- -- Calls P.Luaname but using Module:Arguments


function p.name(frame)
function p.name(frame)