My iphone app supposed to resolve address based on latitude and longitude of the user. reverseGeocodeLocation works fine, but results are in english.
Is there a way to localize the results to other languages?
couldnt find any information about it at apple or anywhere else.
The code I use is:
CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
CLLocation *location = [[[CLLocation alloc]
initWithLatitude:coord.latitude longitude:coord.longitude] autorelease];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
[self displayError:error];
return;
}
if(placemarks && placemarks.count > 0)
{
//do something
CLPlacemark *topResult = [placemarks objectAtIndex:0];
NSString *addressTxt = [NSString stringWithFormat:@"%@ %@,%@ %@",
[topResult subThoroughfare],[topResult thoroughfare],
[topResult locality], [topResult administrativeArea]];
}
}
Since iOS11, apple provides us with another API which can set locale to print localized language.
i found how to localize country name, maybe it'll help:
insert any country id instead @"en_US"
Solution for Swift 4, iOS 11
You can force to get geocoding results in chosen locale language by setting argument:
preferredLocale: Locale.init(identifier: "en_US")
.Mattt Thompson has a great writeup on using a method from the AddressBookUI.framework for localizing addresses on his site NSHipster. He also has a formatting library on github which contains a class for doing this type of localization which uses the AddressBookUI.framework approach he has described.