9

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.

Anto Jurković
  • 11,188
  • 2
  • 29
  • 42
Dim
  • 4,527
  • 15
  • 80
  • 139
  • `Geocoder geocoder = new Geocoder(MainApplication.getAppContext(), Locale.ENGLISH);` is working for me. API 16 – Alaa M. Jul 31 '15 at 11:54

3 Answers3

3

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

HoangYell
  • 4,100
  • 37
  • 31
2

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.

John
  • 7,507
  • 3
  • 52
  • 52
0

I don't think this is possible. Street names are street names. They don't get translated. You have a name. Your name is your name, no matter what language anybody may speak. You don't "translate" your name when you talk to people in foreign languages.

A Geocoder is just a database that maps Geocoordinates to other entitities. In general you won't find multiple names for a street. There are a few instances where names are translated (city names, for example, can be translated into multiple languages), but theese are the exception and not the rule.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • The street name not need to be translated, just shown in English. For example, your name is David, in Chinese its 大卫. Google maps can be seen in different languages. In Israel there is Ben-Gurion street, via Geocoder my result is בן-גוריון that is Ben-Gurion in English, but I wish it to be shown in English instead of Hebrew. – Dim Feb 12 '14 at 07:27
  • @DanM have a look [here](http://stackoverflow.com/questions/19059948/why-geocoder-from-google-maps-is-returning-japanese-character/19060980#19060980). If the street name is labeled this way you can't do much about it. A translation isn't available for all data (like David said already). The only way is to translate it your own. – Steve Benett Feb 12 '14 at 08:24