Get the name of the state in Deutsch using OpenStreetMap

351 views Asked by At

Currently I am using below url to get details of given address.

link

respective code in controller to generate above url is as below:

var query = [address.streetName, address.streetNumber, address.zipCode, address.city, 'Deutschland'].join(' ');

L.Control.Geocoder.jsonp('https://nominatim.openstreetmap.org/search/', {
 q: query,
 limit: 1,
 format: 'json'
}, function (data) {
  if (0 < data.length && ('way' === data[0].osm_type || 'house' === data[0].type)) {
    //do something here
  }
}, this, 'json_callback');

The above query will return result like below:

"place" display_name : "12, Dolivostraße, Pallaswiesenviertel, Darmstadt, Regierungsbezirk Darmstadt, Hesse, 64293, Germany" importance : 0.111 lat : "49.8766854" licence : "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright" lon : "8.6396259" osm_id : "1791379113" osm_type : "node" place_id : "18711662" type : "house"

I want to have 'Hessen' (which is the name used in Germany) rather than 'Hesse'. How to achieve this? Any help would be great :)

1

There are 1 answers

0
scai On

See the Nominatim documentation. It mentions parameter accept-language:

Preferred language order for showing search results, overrides the value specified in the "Accept-Language" HTTP header. Either uses standard rfc2616 accept-language string or a simple comma separated list of language codes.

It allows you to specify a list of languages according to the Accept-Language request-header described in RFC2616. To prefer German first and English second simply add &accept-language=de,en to your URL.