Jump to content

Module:Country extract

From Simple English Wikipedia, the free encyclopedia
Revision as of 10:16, 7 January 2016 by Rich Farmbrough (talk | changes)

local p = {}
--
-- to enable us to replicate the current functioning of CountryAbbr and CountryAbbr2
-- We need to deal with 
-- 1 alternative names ISO 3166 should do that
-- 2 {{<name>}}
-- 3 [ [<name>] ]
-- 4 [ [<name>|<junk>] ]
-- 5 [ [image:flag of <country>.[svg|gif|png|jpg]|\d+px] ]
--

function p.extractCountry(frame)
   local string= mw.ustring.toNFC (frame.args[1])
   local match=nil;
   match = mw.ustring.match(string, "Flag of ([^\.]*)")
   if (match) then 
      return match
   end 
   match = mw.ustring.match(string, "([%a -]*)")
   if (match) then 
      return match
   end
   rv = mw.ustring.sub(string,1,3)
   return  rv
end

--[[ 


]]

function p.helper(frame)
   local rv= mw.ustring.toNFC (frame.args[1])


   return rv
end

return p