google-maps-services-java icon indicating copy to clipboard operation
google-maps-services-java copied to clipboard

How to specify the language for the response data?

Open timothyTheCoder opened this issue 8 years ago • 5 comments

E.g. the response of any request should always be in a specific language e.g. English, even if the request contains the French city name like Bruxelles, I would like "Brussels" as the response.

Is this possible?

Thanks, T

timothyTheCoder avatar Apr 23 '18 14:04 timothyTheCoder

All the requests have a language parameter.

domesticmouse avatar Apr 24 '18 01:04 domesticmouse

Thank you for your response. Yes I have noticed the Google maps API has a language and a region parameter but none seem to work properly. I have 2 questions/issues here:

  • how to specify the language in the Java API?

GeoApiContext.Builder().language(String language) would be great but haven't found it. GeoApiContext.Builder().param(String key, String value) would be great but haven't found it.

  • how to always get the correct address in the language specified? Here is the issue in more detail: I always get the actual Dutch version but not the English version even when I have no Dutch version configured in Chrome.
    Tested it in Chrome directly: Example 1:
GIVEN 
  Language French
 Google Chrome ONLY set to use English language
WHEN
   https://maps.googleapis.com/maps/api/geocode/json?key=[APIKEY]&address=parvis+st+gudule+5+-+1000+Brussels%2C+Belgium+%28Belgium%29&language=fr
THEN
    expect Bruxelles BUT returns "Brussel" Flemish version.
screen shot 2018-04-24 at 09 28 15

Example2:

GIVEN 
  Language English
 Google Chrome ONLY set to use English language
WHEN
   https://maps.googleapis.com/maps/api/geocode/json?key=[APIKEY]&address=parvis+st+gudule+5+-+1000+Brussels%2C+Belgium+%28Belgium%29&language=en
THEN
    expect Brussels BUT returns "Brussel" Flemish version.
screen shot 2018-04-24 at 09 30 35 The country IS translated correctly but not the city.

I'm thinking this needs to be done in another way? Any help is welcome.

timothyTheCoder avatar Apr 24 '18 07:04 timothyTheCoder

Here is the DirectionsApiRequest language parameter Javadoc. That's how you pass through the language to the web services.

domesticmouse avatar Apr 25 '18 01:04 domesticmouse

HI, thanks for the feedback. How did I not see that? Even with the parameter being set to e.g. e-US, the response will always be in Dutch (except the country as that is in the correct language of the parameter but everything else keeps being returned in Dutch) I will just send a request to Google Translate API which returns what I need.

timothyTheCoder avatar Apr 25 '18 08:04 timothyTheCoder

That sounds like a bug. Can you raise it on the appropriate web service bug tracker?

domesticmouse avatar Apr 26 '18 03:04 domesticmouse