3 namespace Drupal\Core\Locale;
5 use Drupal\Core\Extension\ModuleHandlerInterface;
8 * Provides list of countries.
10 class CountryManager implements CountryManagerInterface {
13 * The module handler service.
15 * @var \Drupal\Core\Extension\ModuleHandlerInterface
17 protected $moduleHandler;
20 * An array of country code => country name pairs.
27 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
29 public function __construct(ModuleHandlerInterface $module_handler) {
30 $this->moduleHandler = $module_handler;
34 * Get an array of all two-letter country code => country name pairs.
37 * An array of country code => country name pairs.
39 public static function getStandardList() {
41 'AC' => t('Ascension Island'),
43 'AE' => t('United Arab Emirates'),
44 'AF' => t('Afghanistan'),
45 'AG' => t('Antigua and Barbuda'),
46 'AI' => t('Anguilla'),
49 'AN' => t('Netherlands Antilles'),
51 'AQ' => t('Antarctica'),
52 'AR' => t('Argentina'),
53 'AS' => t('American Samoa'),
55 'AU' => t('Australia'),
57 'AX' => t('Åland Islands'),
58 'AZ' => t('Azerbaijan'),
59 'BA' => t('Bosnia and Herzegovina'),
60 'BB' => t('Barbados'),
61 'BD' => t('Bangladesh'),
63 'BF' => t('Burkina Faso'),
64 'BG' => t('Bulgaria'),
68 'BL' => t('Saint Barthélemy'),
72 'BQ' => t('Caribbean Netherlands'),
76 'BV' => t('Bouvet Island'),
77 'BW' => t('Botswana'),
81 'CC' => t('Cocos [Keeling] Islands'),
82 'CD' => t('Congo - Kinshasa'),
83 'CF' => t('Central African Republic'),
84 'CG' => t('Congo - Brazzaville'),
85 'CH' => t('Switzerland'),
86 'CI' => t('Côte d’Ivoire'),
87 'CK' => t('Cook Islands'),
89 'CM' => t('Cameroon'),
91 'CO' => t('Colombia'),
92 'CP' => t('Clipperton Island'),
93 'CR' => t('Costa Rica'),
95 'CV' => t('Cape Verde'),
97 'CX' => t('Christmas Island'),
99 'CZ' => t('Czech Republic'),
100 'DE' => t('Germany'),
101 'DG' => t('Diego Garcia'),
102 'DJ' => t('Djibouti'),
103 'DK' => t('Denmark'),
104 'DM' => t('Dominica'),
105 'DO' => t('Dominican Republic'),
106 'DZ' => t('Algeria'),
107 'EA' => t('Ceuta and Melilla'),
108 'EC' => t('Ecuador'),
109 'EE' => t('Estonia'),
111 'EH' => t('Western Sahara'),
112 'ER' => t('Eritrea'),
114 'ET' => t('Ethiopia'),
115 'FI' => t('Finland'),
117 'FK' => t('Falkland Islands'),
118 'FM' => t('Micronesia'),
119 'FO' => t('Faroe Islands'),
122 'GB' => t('United Kingdom'),
123 'GD' => t('Grenada'),
124 'GE' => t('Georgia'),
125 'GF' => t('French Guiana'),
126 'GG' => t('Guernsey'),
128 'GI' => t('Gibraltar'),
129 'GL' => t('Greenland'),
132 'GP' => t('Guadeloupe'),
133 'GQ' => t('Equatorial Guinea'),
135 'GS' => t('South Georgia and the South Sandwich Islands'),
136 'GT' => t('Guatemala'),
138 'GW' => t('Guinea-Bissau'),
140 'HK' => t('Hong Kong SAR China'),
141 'HM' => t('Heard Island and McDonald Islands'),
142 'HN' => t('Honduras'),
143 'HR' => t('Croatia'),
145 'HU' => t('Hungary'),
146 'IC' => t('Canary Islands'),
147 'ID' => t('Indonesia'),
148 'IE' => t('Ireland'),
150 'IM' => t('Isle of Man'),
152 'IO' => t('British Indian Ocean Territory'),
155 'IS' => t('Iceland'),
158 'JM' => t('Jamaica'),
162 'KG' => t('Kyrgyzstan'),
163 'KH' => t('Cambodia'),
164 'KI' => t('Kiribati'),
165 'KM' => t('Comoros'),
166 'KN' => t('Saint Kitts and Nevis'),
167 'KP' => t('North Korea'),
168 'KR' => t('South Korea'),
170 'KY' => t('Cayman Islands'),
171 'KZ' => t('Kazakhstan'),
173 'LB' => t('Lebanon'),
174 'LC' => t('Saint Lucia'),
175 'LI' => t('Liechtenstein'),
176 'LK' => t('Sri Lanka'),
177 'LR' => t('Liberia'),
178 'LS' => t('Lesotho'),
179 'LT' => t('Lithuania'),
180 'LU' => t('Luxembourg'),
183 'MA' => t('Morocco'),
185 'MD' => t('Moldova'),
186 'ME' => t('Montenegro'),
187 'MF' => t('Saint Martin'),
188 'MG' => t('Madagascar'),
189 'MH' => t('Marshall Islands'),
190 'MK' => t('Macedonia'),
192 'MM' => t('Myanmar [Burma]'),
193 'MN' => t('Mongolia'),
194 'MO' => t('Macau SAR China'),
195 'MP' => t('Northern Mariana Islands'),
196 'MQ' => t('Martinique'),
197 'MR' => t('Mauritania'),
198 'MS' => t('Montserrat'),
200 'MU' => t('Mauritius'),
201 'MV' => t('Maldives'),
204 'MY' => t('Malaysia'),
205 'MZ' => t('Mozambique'),
206 'NA' => t('Namibia'),
207 'NC' => t('New Caledonia'),
209 'NF' => t('Norfolk Island'),
210 'NG' => t('Nigeria'),
211 'NI' => t('Nicaragua'),
212 'NL' => t('Netherlands'),
217 'NZ' => t('New Zealand'),
221 'PF' => t('French Polynesia'),
222 'PG' => t('Papua New Guinea'),
223 'PH' => t('Philippines'),
224 'PK' => t('Pakistan'),
226 'PM' => t('Saint Pierre and Miquelon'),
227 'PN' => t('Pitcairn Islands'),
228 'PR' => t('Puerto Rico'),
229 'PS' => t('Palestinian Territories'),
230 'PT' => t('Portugal'),
232 'PY' => t('Paraguay'),
234 'QO' => t('Outlying Oceania'),
235 'RE' => t('Réunion'),
236 'RO' => t('Romania'),
240 'SA' => t('Saudi Arabia'),
241 'SB' => t('Solomon Islands'),
242 'SC' => t('Seychelles'),
245 'SG' => t('Singapore'),
246 'SH' => t('Saint Helena'),
247 'SI' => t('Slovenia'),
248 'SJ' => t('Svalbard and Jan Mayen'),
249 'SK' => t('Slovakia'),
250 'SL' => t('Sierra Leone'),
251 'SM' => t('San Marino'),
252 'SN' => t('Senegal'),
253 'SO' => t('Somalia'),
254 'SR' => t('Suriname'),
255 'SS' => t('South Sudan'),
256 'ST' => t('São Tomé and Príncipe'),
257 'SV' => t('El Salvador'),
258 'SX' => t('Sint Maarten'),
260 'SZ' => t('Swaziland'),
261 'TA' => t('Tristan da Cunha'),
262 'TC' => t('Turks and Caicos Islands'),
264 'TF' => t('French Southern Territories'),
266 'TH' => t('Thailand'),
267 'TJ' => t('Tajikistan'),
268 'TK' => t('Tokelau'),
269 'TL' => t('Timor-Leste'),
270 'TM' => t('Turkmenistan'),
271 'TN' => t('Tunisia'),
274 'TT' => t('Trinidad and Tobago'),
277 'TZ' => t('Tanzania'),
278 'UA' => t('Ukraine'),
280 'UM' => t('U.S. Outlying Islands'),
281 'US' => t('United States'),
282 'UY' => t('Uruguay'),
283 'UZ' => t('Uzbekistan'),
284 'VA' => t('Vatican City'),
285 'VC' => t('Saint Vincent and the Grenadines'),
286 'VE' => t('Venezuela'),
287 'VG' => t('British Virgin Islands'),
288 'VI' => t('U.S. Virgin Islands'),
289 'VN' => t('Vietnam'),
290 'VU' => t('Vanuatu'),
291 'WF' => t('Wallis and Futuna'),
295 'YT' => t('Mayotte'),
296 'ZA' => t('South Africa'),
298 'ZW' => t('Zimbabwe'),
302 natcasesort($countries);
308 * Get an array of country code => country name pairs, altered by alter hooks.
311 * An array of country code => country name pairs.
313 * @see \Drupal\Core\Locale\CountryManager::getStandardList()
315 public function getList() {
316 // Populate the country list if it is not already populated.
317 if (!isset($this->countries)) {
318 $this->countries = static::getStandardList();
319 $this->moduleHandler->alter('countries', $this->countries);
322 return $this->countries;