You are here

function _node_import_location_get_country_code in Node import 5

Convert the country from human-readable form to two-letter country code.

1 call to _node_import_location_get_country_code()
location_node_import_prepare in supported/location.inc
Implementation of hook_node_import_prepare().

File

supported/location.inc, line 137

Code

function _node_import_location_get_country_code($country) {
  static $iso_list;
  static $country_list;
  if (!isset($iso_list)) {
    $iso_list = location_get_iso3166_list();
    $country_list = array_flip(array_map('strtolower', $iso_list));
  }
  $country = trim(strtolower($country));
  if (isset($iso_list[$country])) {
    return $country;
  }
  if (isset($country_list[$country])) {
    return $country_list[$country];
  }
  return '';
}