I am using Geocoder to get address from lan/lat coordinates. The problem is that the address is in local language (the street name usually). How can I set it to be only in English?
I am using:
Geocoder geocoder = new Geocoder(Context, Locale.getDefault());
Tried:
Geocoder geocoder = new Geocoder(Context, Locale.ENGLISH);
Geocoder geocoder = new Geocoder(Context, Locale.US);
With no luck.
API 19
The answer is not completely correct I think.
I have just had that case, when I set the GeoCoder locale to English then I get wrong street names.
It does not translate them but it removed language specific parts, that's a concern for me.
"Straße" became "St" for example.
The Google Maps HTTP Geocoder API is different in this regard, when I set an english language the streets are returned correctly just the tested country was translated (Austria instead of Österreich).
As many people use the HTTP API as fallback in case the Geocoder fails this can be a problem, like in my case.
My solution is to always use the locale of the country for BOTH APIs, then the results match.
The HTTP API has a &language parameter which understands Local.toString() as value;
The Geocoder can be initlized like in the original question shown.
create a new locate instance like this:
Locale aLocale = new Builder().setLanguage("en").setScript("Latn").setRegion("RS").build();
Geocoder geocoder = new Geocoder(context,aLocale);
https://developer.android.com/reference/java/util/Locale.Builder.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With