Is this the expected behavior of the API?
Yes, this is expected result. Even if you specify a language, it will return the response in that language only if there is one available, if not it will return the response in the language it was originally entered in.
Case 1:
- Milan: As a Milan is city. Therefore,there are available results in almost every language. Almost all the major city through out the world have results in every language. By default, you will get result in English.
Case 2:
- Via della Spiga: As it is a street. Right now, the results are only available in Italian as they were most possible entered in Italian.
Result when you search "Via della Spiga" in Google Map:
To learn more about this:
Translation of Places information into language specified by request. In this a request for a feature is asked that tells the developer in which language the results are so that they can take care of data accordingly, I personally think that would be great till the issue has not been fixed.
language parameter in place/details request not working
Both of the above issues are about 2 year old. Yet, Google is unable to resolve this issues.
One way to possibly solve this problem is by using textsearch:
As you can convert most of administrative area/city into any language name by using textsearch:
`https://maps.googleapis.com/maps/api/place/textsearch/json?query=Lombardia&lang??uage=Your_language&key=YOUR_API_KEY`
Example: Converting "Lombardia"
into a chinese language:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Lombardia&language=zh-CN&key=YOUR_API
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "意大利伦巴第",
"geometry" : {
"location" : {
"lat" : 45.47906709999999,
"lng" : 9.8452433
},
"viewport" : {
"northeast" : {
"lat" : 46.6351853,
"lng" : 11.4276993
},
"southwest" : {
"lat" : 44.6796491,
"lng" : 8.4978605
}
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id" : "02401d0909d69ca5c69de799e193caf84acc41f9",
"name" : "伦巴第",
"place_id" : "ChIJf4M-GsNEgUcR1JMVKCIm8qY",
"reference" : "CoQBfQAAAEKCAV-1Ec-V2ZfnWsCk_elhlEXckc_k94jBYlU7k5ivhrqPlWd24aSAa5fqNTfwKKhU0wSsZFv42aMm1BrG5wEwZNGKwFqELxMEt0ye7KFfBgVtfHZbqeiBx3hEH8Iq60wwW--edqpROkBTjHrxIwisCGJwhCzKKkQ9H6FdfW_aEhAnmI0ZOFk1KGaGms4IqTOiGhRX5iErBIwnmLos4U9Ggs325MmcEA",
"types" : [ "administrative_area_level_1", "political" ]
}
],
"status" : "OK"
}
Lombardia in chinese is 意大利伦巴第
When you search for placeID details, you get address_components
array:
"address_components" : [
{
"long_name" : "Via della Spiga",
"short_name" : "Via della Spiga",
"types" : [ "route" ]
},
{
"long_name" : "Milano",
"short_name" : "Milano",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Milano",
"short_name" : "MI",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Lombardia",
"short_name" : "Lombardia",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Italy",
"short_name" : "IT",
"types" : [ "country", "political" ]
}
]
So if you loop over the above array and use textsearch then you will get almost consistent address in a particular language.