Localization for Autocomplete API results

  • 5
  • Question
  • Updated 5 years ago
Is there a way to get localized results from the autocomplete API? Specifically, I'd like the "name" field to be in the correct format. For example, if I make the request:

http://autocomplete.wunderground.com/...

in German, the name field for Berlin would be "Berlin, Deutscheland", (or whatever it needs to be) instead of "Berlin, Germany".

I tried adding /lang:DL/ but it didn't like it.
Photo of jasoncausey

jasoncausey

  • 5 Posts
  • 0 Reply Likes

Posted 6 years ago

  • 5
Photo of David Fairman

David Fairman

  • 6 Posts
  • 2 Reply Likes
The name field for the autocomplete API actually already is localized, it is based off of the language setting in the browser that makes the call. So if your browser is set with German as the default language, you will get a different result of names from the autocomplete than if your browser was set with English as the default language.

If you are writing this into an application, your request will need to have an "Accept-Language" field included in the HTTP header. For example if you want to return results in German:

Accept-Language: de

Must be passed in the HTTP header.

Noteworthy: If you are testing this case out, you will want to search for "Flughafen Berlin" instead of "Berlin" if you are setting the autocomplete to return results in German.
Photo of dobry

dobry

  • 23 Posts
  • 1 Reply Like
When calling from a mobile app there is no HTTP header. I tried to add "&lang=DL" but it didn't work. Hope you can enable this.
Photo of jasoncausey

jasoncausey

  • 5 Posts
  • 0 Reply Likes
Thanks for the information David.

However, I'm making the autocomplete request from within a Flash application, and when I try to send the http header, I get a crossdomain security violation.

Is there any way the crossdomain.xml file on autocomplete.wunderground.com can be changed to allow http headers (using the allow-http-request-headers-from node)?

FYI: http://learn.adobe.com/wiki/download/...

Thanks.
Photo of David Fairman

David Fairman

  • 6 Posts
  • 2 Reply Likes
I have added the ability to select the language returned by the autocomplete by adding a "&lang=" query variable to the url string. The way this currently functions, it will return the results available for the specified language followed by all english results (which is the same way the autocomplete works when reading from the http header). If the language value sent in is invalid (such as "&lang=zz") the autocomplete will return in english. If no "&lang=" is supplied the autocomplete will base the language off of the HTTP header (if there are no proper values in the http header it will return in english).

So for a few examples:

if you search with: http://autocomplete.wunderground.com/...
- first value is "madrid, Spain"

if you search with: http://autocomplete.wunderground.com/...
- first value is now "Madrid, Espagne"

Hope this helps! Jason, this should fix your cross domain issue as well since you now can pass the language in the autocomplete query and do not need to deal with the http header.
Photo of jasoncausey

jasoncausey

  • 5 Posts
  • 0 Reply Likes
Thanks so much - that's perfect...however - after doing a couple quick queries, I didn't notice any difference when I passed "de" as the lang query variable.

For example: http://autocomplete.wunderground.com/...

gives the same results as: http://autocomplete.wunderground.com/...

(except that it seems to add an entry for "Berlinhafen, Papua-Neuguinea", that the english version doesn't have...which is odd)
Photo of dobry

dobry

  • 23 Posts
  • 1 Reply Like
Thank you David.
I see that the ISO country code (e.g. "de") in lower case instead of the WUG country code (e.g. "DL") in upper case, like in the other services, is needed.
I would be nice if we also could send the WUG country code and you would convert it to the ISO country code. Means if you receive an uppercase country code the conversation is needed.
Photo of Temps

Temps

  • 13 Posts
  • 0 Reply Likes
&lang=de doesn't work for me too, I always get english answers.
Photo of jasoncausey

jasoncausey

  • 5 Posts
  • 0 Reply Likes
Any update on this topic? This is a feature that has been requested by our client, and it seems like we're really close to actually getting it :)

Thanks!
Photo of jasoncausey

jasoncausey

  • 5 Posts
  • 0 Reply Likes
This has become a critical issue for our application. In addition to our "Shower" plan, we use the autocomplete API as a way for users to set their location, but it HAS to be localized.

Is there a chance this will get addressed soon, or should we start looking into other alternatives to achieve this functionality?

Thanks.
Photo of DarkPark

DarkPark

  • 4 Posts
  • 0 Reply Likes
Hello.
&lang=ru doesn't work
will there be the Russian language support?
Photo of Juliska

Juliska

  • 1 Post
  • 0 Reply Likes
It work.
&lang:RU

<![CDATA[Пасмурно. Температура не выше 75F. Скорость Ветра: 10-15 миль/ч. Направление Ветра: В-ЮВ.]]>

<![CDATA[Пасмурно. Температура не выше 24C. Скорость Ветра: 15-20 км/ч. Направление Ветра: В-ЮВ.]]>
Photo of DarkPark

DarkPark

  • 4 Posts
  • 0 Reply Likes
Photo of dieselpuppet

dieselpuppet

  • 8 Posts
  • 0 Reply Likes
http://autocomplete.wunderground.com/...

&lang=ru
works. And use city in Russian too
Photo of DarkPark

DarkPark

  • 4 Posts
  • 0 Reply Likes
JFYI
the localization (at least for Russian) is case sensitive

http://autocomplete.wunderground.com/...
http://autocomplete.wunderground.com/...
give different results
actually the first one gives none.