I'm using Google's Place API to Autocomplete the cities names typed by the users (webpage). The API is loaded passing the language (pt-BR) as parameter and the text box is being filled correctly in portuguese, but when the method getPlace() is executed it returns the results (country and administrative_area_level_1) in English.
I'm not sure if the problem is the Google API, their translation to portuguese or something that I missed. I've tried to load It passing spanish (es), english (en) and italian (it) as language's parameter and working as expected.
Here is how I am loading:
<script src="https://maps.googleapis.com/maps/api/js?key=[myapikey]&signed_in=true&libraries=places&callback=initAutocomplete&language=pt-BR" async defer></script>
... and how I am getting the results based on Google's Sample code:
// Get the place details from the autocomplete object.
var place = autocomplete.getPlace();
I'm also using the reverse geocoding API passing the place_id and the issue is the same (C# code).
var apikey = "[myserverapikey]";
var requestUri = string.Format("https://maps.googleapis.com/maps/api/geocode/json?place_id={0}&key={1}", place_id, apikey);
var idiomas = new string[] {"pt-BR", "es", "en-us", "it"};
string responseContent = string.Empty;
foreach (var idioma in idiomas)
{
HttpWebRequest request = WebRequest.Create(requestUri) as HttpWebRequest;
request.Headers.Add(HttpRequestHeader.AcceptLanguage, idioma);
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
StreamReader reader = new StreamReader(response.GetResponseStream());
var jsontext = reader.ReadToEnd().Trim();
responseContent += jsontext;
var json = JsonConvert.DeserializeObject<GoogleGeoCodeResponse>(jsontext);
}
return Json(responseContent, JsonRequestBehavior.AllowGet);
I've checked the documentation and the pt-BR is supported: Google API Supported Languages