Closed (outdated)
Project:
Location
Version:
6.x-3.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 May 2011 at 12:59 UTC
Updated:
20 Jul 2016 at 05:49 UTC
Jump to comment: Most recent
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
Comment #1
hutch commentedMakes 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 ;-)
Comment #2
alexbk66- commentedI 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
Comment #3
legolasboClosing old D6 issues as D6 is end of life