I found that for Japan some state names have trailing space, so when user enters the name without the space, it doesn't match.

I modified the function to trim them, I wonder if it's good?

// @@@ New in 3.x, document.
/**
 * Fetch the provinces for a country.
 */
function location_get_provinces($country = 'us') {
  static $provinces = array();
  location_standardize_country_code($country);
  if (isset($provinces[$country])) {
    return $provinces[$country];
  }
  if ($cache = cache_get("provinces:$country", 'cache_location')) {
    $provinces[$country] = $cache->data;
    return $provinces[$country];
  }
  location_load_country($country);
  $func = 'location_province_list_'. $country;
  if (function_exists($func)) {
    $provinces[$country] = $func();
    for($i=0; $i<count($provinces[$country]); $i++) {
      $orig = $provinces[$country][$i];
      $trimmed = trim($orig); // alexbk66
      if($orig != $trimmed) {
        dsm($orig, 'Trimmed'); // TEMP
        $provinces[$country][$i] = $trimmed;
      }
    }
    cache_set("provinces:$country", $provinces[$country], 'cache_location');
    return $provinces[$country];
  }
  return array();
}

Comments

hutch’s picture

Makes more sense to clean up the array it's fetching, eg supported/location.jp.inc which contains entries like
'09' => "Totigi (Tochigi) ",
This is unuseable as is.

The names used should be those most likely to be recognised in the world at large so if anyone feels competent to make these decisions please supply a fix for location.jp.inc ;-)

alexbk66-’s picture

I thought that JP isn't only the case, but I confirmed that it's only a problem for JP, so you may be right.

HobbyBlob.com

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing old D6 issues as D6 is end of life