public static function toIso3($MauticCountryPlainText)
{
// there are duplicate countries in the list, so we need to normalize that into the ISO3 Codes
$Iso3_temp = array_search(strtolower($MauticCountryPlainText), array_map('strtolower', self::countries) );
if (!$Iso3_temp) {
return "";
}
$Iso3 = str_replace("_B", "", $Iso3_temp );
return $Iso3;
}
public static function toMauticText($Iso3)
{
$Iso3 = strtoupper($Iso3);
if ( !array_key_exists($Iso3, self::countries )) {
return "";
}
return self::countries[$Iso3];
}
`
---
Want to back this issue? **[Post a bounty on it!](https://app.bountysource.com/issues/80368675-mautic-country-handling-fix?utm_campaign=plugin&utm_content=tracker%2F10940535&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://app.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10940535&utm_medium=issues&utm_source=github).
Mautic stored the countries in plain text (not iso3) I wrote a small wrapper to covert the iso3 to the mautic plain text equivalent
` // based on : app/bundles/CoreBundle/Assets/json/countries.json : 2018 May 30 const countries = [ "AFG" => "Afghanistan", "ALA" => "Åland Islands", "ALB" => "Albania", "DZA" => "Algeria", "AND" => "Andorra", "AGO" => "Angola", "AIA" => "Anguilla", "ATA" => "Antarctica", "ATG" => "Antigua and Barbuda", "ARG" => "Argentina", "ARM" => "Armenia", "ABW" => "Aruba", "AUS" => "Australia", "AUT" => "Austria", "AZE" => "Azerbaijan", "BHS" => "Bahamas", "BHR" => "Bahrain", "BGD" => "Bangladesh", "BRB" => "Barbados", "BLR" => "Belarus", "BEL" => "Belgium", "BLZ" => "Belize", "BEN" => "Benin", "BMU" => "Bermuda", "BTN" => "Bhutan", "BOL" => "Bolivia", "BES" => "Bonaire Saint Eustatius and Saba", "BIH" => "Bosnia and Herzegovina", "BWA" => "Botswana", "BVT" => "Bouvet Island", "BRA" => "Brazil", "BRN" => "Brunei", "BGR" => "Bulgaria", "BFA" => "Burkina Faso", "BDI" => "Burundi", "CPV" => "Cape Verde", "KHM" => "Cambodia", "CMR" => "Cameroon", "CAN" => "Canada", "CYM" => "Cayman Islands", "CAF" => "Central African Republic", "TCD" => "Chad", "CHL" => "Chile", "CHN" => "China", "COL" => "Colombia", "COM" => "Comoros", "COK" => "Cook Islands", "CRI" => "Costa Rica", "HRV" => "Croatia", "CUB" => "Cuba", "CYP" => "Cyprus", "CZE" => "Czech Republic", "DNK" => "Denmark", "DJI" => "Djibouti", "DMA" => "Dominica", "DOM" => "Dominican Republic", "COG" => "Democratic Republic of the Congo", "TLS" => "East Timor", "ECU" => "Ecuador", "EGY" => "Egypt", "SLV" => "El Salvador", "GNQ" => "Equatorial Guinea", "ERI" => "Eritrea", "EST" => "Estonia", "ETH" => "Ethiopia", "FLK" => "Falkland Islands", "FJI" => "Fiji", "FIN" => "Finland", "FRA" => "France", "GUF" => "French Guiana", "PYF" => "French Polynesia", "GAB" => "Gabon", "GMB" => "Gambia", "GEO" => "Georgia", "DEU" => "Germany", "GHA" => "Ghana", "GIB" => "Gibraltar", "GRC" => "Greece", "GRL" => "Greenland", "GRD" => "Grenada", "GLP" => "Guadeloupe", "GUM" => "Guam", "GTM" => "Guatemala", "GGY" => "Guernsey", "GIN" => "Guinea", "GNB" => "Guinea Bissau", "GUY" => "Guyana", "HTI" => "Haiti", "HMD" => "Heard Island and McDonald Islands", "VAT" => "Holy See", "HND" => "Honduras", "HKG" => "Hong Kong", "HUN" => "Hungary", "ISL" => "Iceland", "IND" => "India", "IDN" => "Indonesia", "IRN" => "Iran", "IRQ" => "Iraq", "IRL" => "Ireland", "ISR" => "Israel", "ITA" => "Italy", "CIV" => "Ivory Coast", "JAM" => "Jamaica", "JPN" => "Japan", "JEY" => "Jersey", "JOR" => "Jordan", "KAZ" => "Kazakhstan", "KEN" => "Kenya", "KIR" => "Kiribati", "KWT" => "Kuwait", "KGZ" => "Kyrgyzstan", "LAO" => "Laos", "LVA" => "Latvia", "LBN" => "Lebanon", "LSO" => "Lesotho", "LBR" => "Liberia", "LBY" => "Libya", "LIE" => "Liechtenstein", "LTU" => "Lithuania", "LUX" => "Luxembourg", "MAC" => "Macao", "MKD" => "Macedonia", "MDG" => "Madagascar", "MWI" => "Malawi", "MYS" => "Malaysia", "MDV" => "Maldives", "MLI" => "Mali", "MLT" => "Malta", "MHL" => "Marshall Islands", "MTQ" => "Martinique", "MRT" => "Mauritania", "MUS" => "Mauritius", "MYT" => "Mayotte", "MEX" => "Mexico", "FSM" => "Micronesia", "MDA" => "Moldova", "MCO" => "Monaco", "MNG" => "Mongolia", "MNE" => "Montenegro", "MSR" => "Montserrat", "MAR" => "Morocco", "MOZ" => "Mozambique", "MMR" => "Myanmar", "NAM" => "Namibia", "NRU" => "Nauru", "NPL" => "Nepal", "NLD" => "Netherlands", "NCL" => "New Caledonia", "NZL" => "New Zealand", "NIC" => "Nicaragua", "NER" => "Niger", "NGA" => "Nigeria", "NIU" => "Niue", "NFK" => "North Korea", "MNP" => "Northern Mariana Islands", "NOR" => "Norway", "OMN" => "Oman", "PAK" => "Pakistan", "PLW" => "Palau", "PSE" => "Palestine", "PAN" => "Panama", "PNG" => "Papua New Guinea", "PRY" => "Paraguay", "PER" => "Peru", "PHL" => "Philippines", "PCN" => "Pitcairn", "POL" => "Poland", "PRT" => "Portugal", "PRI" => "Puerto Rico", "QAT" => "Qatar", "COG_B" => "Republic of the Congo", "REU" => "Réunion", "ROU" => "Romania", "RUS" => "Russia", "RWA" => "Rwanda", "BLM" => "Saint Barthelemy", "SHN" => "Saint Helena Ascension and Tristan da Cunha", "KNA" => "Saint Kitts and Nevis", "LCA" => "Saint Lucia", "MAF" => "Saint Martin", "SPM" => "Saint Pierre and Miquelon", "VCT" => "Saint Vincent and the Grenadines", "WSM" => "Samoa", "SMR" => "San Marino", "STP" => "Sao Tome and Principe", "SAU" => "Saudi Arabia", "SEN" => "Senegal", "SRB" => "Serbia", "SYC" => "Seychelles", "SLE" => "Sierra Leone", "SGP" => "Singapore", "SVK" => "Slovakia", "SVN" => "Slovenia", "SLB" => "Solomon Islands", "SOM" => "Somalia", "ZAF" => "South Africa", "SGS" => "South Georgia and the South Sandwich Islands", "KOR" => "South Korea", "SDN" => "South Sudan", "ESP" => "Spain", "LKA" => "Sri Lanka", "SJM" => "Svalbard and Jan Mayen", "SDN_B" => "Sudan", "SUR" => "Suriname", "SWZ" => "Swaziland", "SWE" => "Sweden", "CHE" => "Switzerland", "SYR" => "Syria", "PYF_B" => "Tahiti", "TWN" => "Taiwan", "TJK" => "Tajikistan", "TZA" => "Tanzania", "THA" => "Thailand", "TGO" => "Togo", "TKL" => "Tokelau", "TON" => "Tonga", "TTO" => "Trinidad and Tobago", "TUN" => "Tunisia", "TUR" => "Turkey", "TKM" => "Turkmenistan", "TCA" => "Turks and Caicos Islands", "TUV" => "Tuvalu", "GBR" => "United Kingdom", "USA" => "United States", "" => "Unknown", "UGA" => "Uganda", "UKR" => "Ukraine", "ARE" => "United Arab Emirates", "URY" => "Uruguay", "UZB" => "Uzbekistan", "VUT" => "Vanuatu", "VEN" => "Venezuela", "VNM" => "Vietnam", "VGB" => "Virgin Islands (British)", "VIR" => "Virgin Islands (U.S.)", "WLF" => "Wallis and Futuna", "ESH" => "Western Sahara", "YEM" => "Yemen", "MKD_B" => "Yugoslavia", "ZMB" => "Zambia", "ZWE" => "Zimbabwe", ];
`