Module:Country code

local p = {} local data = mw.loadData('module:country codes') function p.getsome (frame) --get country by code(1) or country by 1 or return 1 local args = frame.args or frame local countrycode = args[1] or args['1'] local ret = p.getcode({[1] = countrycode}) ret = p.getcountry({[1] = (ret or countrycode)}) return ret end--get some function p.getcountry (frame) --get country by code local args = frame.args or frame local code = args[1] or args['1'] if not code then return end local country = data[mw.ustring.upper(code)] or code return country end --getcountry function p.getcode (frame) --get code by country --1st param: country; 2nd: code length --2 = 0: digital country code local args = frame.args or frame local country, codelen = args[1] or args['1'], args[2] or args['2'] or 2 local numk if (not country) or (not codelen) then return end codelen = tonumber(codelen) if not codelen then return end country = mw.ustring.upper(country) for k, v in pairs(data) do       numk = tonumber(k) if codelen > 0 then if (#k == codelen) and (not numk) and (mw.ustring.upper(v) == country) then return k           end elseif numk and (mw.ustring.upper(v) == country) then return k       end end end --getcode return p