When i call
geocoder reverseGeocodeLocation:currentLoc completionHandler:
i get all the data (city, county, ...) in a language according to locale set on iphone.
How can i force to always get this data in English?
When i call
geocoder reverseGeocodeLocation:currentLoc completionHandler:
i get all the data (city, county, ...) in a language according to locale set on iphone.
How can i force to always get this data in English?
Update Swift 4:
Just use this code to force the data returned in English:
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:
Where userLocationCL is the current user location.
iOS 11 has a new
-reverseGeocode...
method that accepts a locale to use:Swift signature:
Put whatever locale you like. This example just uses the current locale
You can not force the language of the geo data retrieved from
CLGeocoder
orMKReverseGeocoder
. It will always be the system language of the device. If you want to get the data in English you need to built your own geocoder which is relatively easy to implement with the Google Maps API.Here is a spreadsheet of the supported languages in Google Maps API: https://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1
For future readers, the accepted answer is not true (at least not any more).
Calling
removeObject(forKey:)
is important since you want to reset the returned value inUserDefaults
to the system settings. Some answers make you hold the original value from callingUserDefaults.standard.object(forKey: "AppleLanguages")
and set it after getting the address, but this will stop yourUserDefaults
from being in sync with the global Language Preferences in iOS "Settings" app.