Template:GetRegion
From Pestinfo-Wiki
The template takes one parameter (the name of a country page) and converts it into a new string which includes the appropriate region. E.g. the country "U.S.A. (SE)" will be converted to "2A,U.S.A. (SE)" where "2A" is the regional code for "North/Central America". The regional codes are needed for sorting a list of countries according to their regions. If no category is found, the code 9Z (= other countries) is assigned.
See also the corresponding Template:ShowRegion for converting a regional code back to the name of a region.
The template has the following structure:
1. Determine the first region (category) for the country and assign it to the variable "Region". {{#vardefine:Region|{{GetCategory|{{{1}}} }} }} 2. Determine the regional code and assign it to the variable "RegCode". {{#vardefine:RegCode| {{#switch: {{#var:Region}} | Europe - Central = 1C | Europe - East = 1E | Europe - North = 1N | Europe - South = 1S | North/Central America = 2A | South America = 2B | Caribbean Islands = 2C | Asia - East = 3A | Australia/Pacific = 3B | Asia - West = 3C | Near East = 3D | Africa - North = 4A | Africa - East = 4B | Africa - West = 4C | Africa - South = 4D | 9Z }} }} 3. Return the combination of regional code and country {{#var:RegCode}},{{{1}}}