When i call
geocoder reverseGeocodeLocation:currentLoc completionHandler:
i get all the data (city, county, ...) in a language according t
Update Swift 4:
Just use this code to force the data returned in English:
func fetchCityAndCountry(from location: CLLocation, completion: @escaping (_ locality: String?, _ country: String?, _ error: Error?) -> ()) {
CLGeocoder().reverseGeocodeLocation(location, preferredLocale: Locale.init(identifier: "en")) { placemarks, error in
completion(placemarks?.first?.locality,
placemarks?.first?.country,
error)
}
}
You can change the Locale identifier to translate the data into any other language ("ca", "es", "fr", "de"...).
This function can be called, for instance, like this:
fetchCityAndCountry (from: userLocationCL) { locality, country, error in
guard let locality = locality, let country = country, error == nil else { return }
// your code
}
Where userLocationCL is the current user location.