Commit bc70abb3 authored by webchick's avatar webchick

Issue #1068840 by sun, TR, Alan D., droplet, Damien Tournoud, tim.plunkett:...

Issue #1068840 by sun, TR, Alan D., droplet, Damien Tournoud, tim.plunkett: Fixed core/includes/standard.inc contains inaccurate country data.
parent 6dd3740f
......@@ -39,7 +39,7 @@ function standard_country_list() {
'AT' => $t('Austria'),
'AU' => $t('Australia'),
'AW' => $t('Aruba'),
'AX' => $t('Aland Islands'),
'AX' => $t('Åland Islands'),
'AZ' => $t('Azerbaijan'),
'BA' => $t('Bosnia and Herzegovina'),
'BB' => $t('Barbados'),
......@@ -52,8 +52,9 @@ function standard_country_list() {
'BJ' => $t('Benin'),
'BL' => $t('Saint Barthélemy'),
'BM' => $t('Bermuda'),
'BN' => $t('Brunei'),
'BO' => $t('Bolivia'),
'BN' => $t('Brunei Darussalam'),
'BO' => $t('Bolivia, Plurinational State of'),
'BQ' => $t('Bonaire, Sint Eustatius and Saba'),
'BR' => $t('Brazil'),
'BS' => $t('Bahamas'),
'BT' => $t('Bhutan'),
......@@ -63,11 +64,11 @@ function standard_country_list() {
'BZ' => $t('Belize'),
'CA' => $t('Canada'),
'CC' => $t('Cocos (Keeling) Islands'),
'CD' => $t('Congo (Kinshasa)'),
'CD' => $t('Congo, The Democratic Republic of the'),
'CF' => $t('Central African Republic'),
'CG' => $t('Congo (Brazzaville)'),
'CG' => $t('Congo'),
'CH' => $t('Switzerland'),
'CI' => $t('Ivory Coast'),
'CI' => $t("Côte d'Ivoire"),
'CK' => $t('Cook Islands'),
'CL' => $t('Chile'),
'CM' => $t('Cameroon'),
......@@ -75,8 +76,8 @@ function standard_country_list() {
'CO' => $t('Colombia'),
'CR' => $t('Costa Rica'),
'CU' => $t('Cuba'),
'CW' => $t('Curaçao'),
'CV' => $t('Cape Verde'),
'CW' => $t('Curaçao'),
'CX' => $t('Christmas Island'),
'CY' => $t('Cyprus'),
'CZ' => $t('Czech Republic'),
......@@ -95,8 +96,8 @@ function standard_country_list() {
'ET' => $t('Ethiopia'),
'FI' => $t('Finland'),
'FJ' => $t('Fiji'),
'FK' => $t('Falkland Islands'),
'FM' => $t('Micronesia'),
'FK' => $t('Falkland Islands (Malvinas)'),
'FM' => $t('Micronesia, Federated States of'),
'FO' => $t('Faroe Islands'),
'FR' => $t('France'),
'GA' => $t('Gabon'),
......@@ -118,7 +119,7 @@ function standard_country_list() {
'GU' => $t('Guam'),
'GW' => $t('Guinea-Bissau'),
'GY' => $t('Guyana'),
'HK' => $t('Hong Kong S.A.R., China'),
'HK' => $t('Hong Kong'),
'HM' => $t('Heard Island and McDonald Islands'),
'HN' => $t('Honduras'),
'HR' => $t('Croatia'),
......@@ -131,7 +132,7 @@ function standard_country_list() {
'IN' => $t('India'),
'IO' => $t('British Indian Ocean Territory'),
'IQ' => $t('Iraq'),
'IR' => $t('Iran'),
'IR' => $t('Iran, Islamic Republic of'),
'IS' => $t('Iceland'),
'IT' => $t('Italy'),
'JE' => $t('Jersey'),
......@@ -144,12 +145,12 @@ function standard_country_list() {
'KI' => $t('Kiribati'),
'KM' => $t('Comoros'),
'KN' => $t('Saint Kitts and Nevis'),
'KP' => $t('North Korea'),
'KR' => $t('South Korea'),
'KP' => $t("Korea, Democratic People's Republic of"),
'KR' => $t('Korea, Republic of'),
'KW' => $t('Kuwait'),
'KY' => $t('Cayman Islands'),
'KZ' => $t('Kazakhstan'),
'LA' => $t('Laos'),
'LA' => $t("Lao People's Democratic Republic"),
'LB' => $t('Lebanon'),
'LC' => $t('Saint Lucia'),
'LI' => $t('Liechtenstein'),
......@@ -162,16 +163,16 @@ function standard_country_list() {
'LY' => $t('Libya'),
'MA' => $t('Morocco'),
'MC' => $t('Monaco'),
'MD' => $t('Moldova'),
'MD' => $t('Moldova, Republic of'),
'ME' => $t('Montenegro'),
'MF' => $t('Saint Martin (French part)'),
'MG' => $t('Madagascar'),
'MH' => $t('Marshall Islands'),
'MK' => $t('Macedonia'),
'MK' => $t('Macedonia, Republic of'),
'ML' => $t('Mali'),
'MM' => $t('Myanmar'),
'MN' => $t('Mongolia'),
'MO' => $t('Macao S.A.R., China'),
'MO' => $t('Macao'),
'MP' => $t('Northern Mariana Islands'),
'MQ' => $t('Martinique'),
'MR' => $t('Mauritania'),
......@@ -206,15 +207,15 @@ function standard_country_list() {
'PM' => $t('Saint Pierre and Miquelon'),
'PN' => $t('Pitcairn'),
'PR' => $t('Puerto Rico'),
'PS' => $t('Palestinian Territory'),
'PS' => $t('Palestine, State of'),
'PT' => $t('Portugal'),
'PW' => $t('Palau'),
'PY' => $t('Paraguay'),
'QA' => $t('Qatar'),
'RE' => $t('Reunion'),
'RE' => $t('Réunion'),
'RO' => $t('Romania'),
'RS' => $t('Serbia'),
'RU' => $t('Russia'),
'RU' => $t('Russian Federation'),
'RW' => $t('Rwanda'),
'SA' => $t('Saudi Arabia'),
'SB' => $t('Solomon Islands'),
......@@ -222,7 +223,7 @@ function standard_country_list() {
'SD' => $t('Sudan'),
'SE' => $t('Sweden'),
'SG' => $t('Singapore'),
'SH' => $t('Saint Helena'),
'SH' => $t('Saint Helena, Ascension and Tristan da Cunha'),
'SI' => $t('Slovenia'),
'SJ' => $t('Svalbard and Jan Mayen'),
'SK' => $t('Slovakia'),
......@@ -231,9 +232,11 @@ function standard_country_list() {
'SN' => $t('Senegal'),
'SO' => $t('Somalia'),
'SR' => $t('Suriname'),
'SS' => $t('South Sudan'),
'ST' => $t('Sao Tome and Principe'),
'SV' => $t('El Salvador'),
'SY' => $t('Syria'),
'SX' => $t('Sint Maarten (Dutch part)'),
'SY' => $t('Syrian Arab Republic'),
'SZ' => $t('Swaziland'),
'TC' => $t('Turks and Caicos Islands'),
'TD' => $t('Chad'),
......@@ -249,20 +252,20 @@ function standard_country_list() {
'TR' => $t('Turkey'),
'TT' => $t('Trinidad and Tobago'),
'TV' => $t('Tuvalu'),
'TW' => $t('Taiwan'),
'TZ' => $t('Tanzania'),
'TW' => $t('Taiwan, Province of China'),
'TZ' => $t('Tanzania, United Republic of'),
'UA' => $t('Ukraine'),
'UG' => $t('Uganda'),
'UM' => $t('United States Minor Outlying Islands'),
'US' => $t('United States'),
'UY' => $t('Uruguay'),
'UZ' => $t('Uzbekistan'),
'VA' => $t('Vatican'),
'VA' => $t('Holy See (Vatican City State)'),
'VC' => $t('Saint Vincent and the Grenadines'),
'VE' => $t('Venezuela'),
'VG' => $t('British Virgin Islands'),
'VI' => $t('U.S. Virgin Islands'),
'VN' => $t('Vietnam'),
'VE' => $t('Venezuela, Bolivarian Republic of'),
'VG' => $t('Virgin Islands, British'),
'VI' => $t('Virgin Islands, U.S.'),
'VN' => $t('Viet Nam'),
'VU' => $t('Vanuatu'),
'WF' => $t('Wallis and Futuna'),
'WS' => $t('Samoa'),
......
#!/bin/php
<?php
/**
* @file
* Updates ISO-3166 codes in standard.inc to latest data.
*
* We rely on the Debian ISO code repository, because it is easily accessible,
* scriptable, in the right human-readable format, and all changes went through
* sufficient FOSS community discussion already.
*/
// Determine DRUPAL_ROOT.
$cwd = $dir = dirname(__FILE__);
while (!defined('DRUPAL_ROOT')) {
if (is_dir($dir . '/core')) {
define('DRUPAL_ROOT', $dir);
}
$dir = dirname($dir);
}
// Determine source data file URI to process.
$uri = $cwd . '/iso_3166.xml';
// Despite its actual file name, at least Firefox merges and converts the path
// and filename into a combined filename.
if (!file_exists($uri)) {
$uri = $cwd . '/iso_3166_iso_3166.xml';
}
// Fall back and default to original Debian source.
if (!file_exists($uri)) {
$uri = 'http://anonscm.debian.org/gitweb/?p=iso-codes/iso-codes.git;a=blob_plain;f=iso_3166/iso_3166.xml;hb=master';
}
// Read in existing codes.
// @todo Allow to remove previously existing country codes.
// @see http://drupal.org/node/1436754
require_once DRUPAL_ROOT . '/core/includes/standard.inc';
$existing_countries = standard_country_list();
$countries = $existing_countries;
// Parse the source data into an array.
$data = simplexml_load_file($uri);
foreach ($data->iso_3166_entry as $entry) {
// Ignore every territory that doesn't have a alpha-2 code.
if (!isset($entry['alpha_2_code'])) {
continue;
}
$name = isset($entry['name']) ? (string) $entry['name'] : (string) $entry['official_name'];
$countries[(string) $entry['alpha_2_code']] = $name;
}
if (empty($countries)) {
echo 'ERROR: Did not find expected alpha_2_code country names.' . PHP_EOL;
exit;
}
// Sort by country code (to minimize diffs).
ksort($countries);
// Produce PHP code.
$out = '';
foreach ($countries as $code => $name) {
// For .po translation file's sake, use double-quotes instead of escaped
// single-quotes.
$name = (strpos($name, '\'') !== FALSE ? '"' . $name . '"' : "'" . $name . "'");
$out .= ' ' . var_export($code, TRUE) . ' => $t(' . $name . '),' . "\n";
}
// Replace the actual PHP code in standard.inc.
$file = DRUPAL_ROOT . '/core/includes/standard.inc';
$content = file_get_contents($file);
$content = preg_replace('/(\$countries = array\(\n)(.+?)(^\s+\);)/ms', '$1' . $out . '$3', $content);
file_put_contents($file, $content);
/**
* No-op script helper.
*/
function get_t() {
return function ($string) {
return $string;
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment