Module:Country

--FROM DEV WIKI--

--[[ https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes Description : Gets data about a country, see format in Module:Country/data Syntax :
 * country-isocode (e.g. fr =="France")

]]--

local p = {} local getArgs = require("Dev:Arguments").getArgs local countryData = mw.loadData("Dev:Country/data") function p.main(frame) local args = getArgs(frame) if args then local countryCode = args[1] or args.code local info = args[2] or args.info return getCountryData(countryCode,info) end end

function p.countrycode(frame) local args = getArgs(frame) if args then local countryCode = args[1] or args.name local bCloseMatch = args["match"] return getCountryCode(countryCode, bCloseMatch) end end

function getCountryData(code,info) if info and code then -- if the code doesn't exist try looking for a country name if not countryData[code] then code = getCountryCode(code) end return countryData[code][info] end end

function getCountryCode(name, bCloseMatch) name = name:lower local tmpName = "" for sCode, sData in pairs(countryData) do       tmpName= string.lower(sData.name) if tmpName == name then return string.lower(sCode) end -- Try the closest match if sData.name:match(name) and bCloseMatch then return string.lower(sCode) end end end

return p