Skip to content

Commit

Permalink
Make nominatim search provider locale aware
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Dec 16, 2021
1 parent 805b71c commit 1e139a1
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 7 deletions.
14 changes: 8 additions & 6 deletions js/SearchProviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Format of search results:
import axios from 'axios';
import {addSearchResults, SearchResultType} from "qwc2/actions/search";
import CoordinatesUtils from 'qwc2/utils/CoordinatesUtils';
import LocaleUtils from 'qwc2/utils/LocaleUtils';

function coordinatesSearch(text, requestId, searchOptions, dispatch) {
const displaycrs = searchOptions.displaycrs || "EPSG:4326";
Expand Down Expand Up @@ -239,7 +240,7 @@ function nominatimSearchResults(obj, requestId) {
groups[entry.class] = {
id: "nominatimgroup" + (groupcounter++),
// capitalize class
title: entry.class.charAt(0).toUpperCase() + entry.class.slice(1),
title: LocaleUtils.trWithFallback("search.nominatim." + entry.class, entry.class.charAt(0).toUpperCase() + entry.class.slice(1)),
items: []
};
results.push(groups[entry.class]);
Expand Down Expand Up @@ -290,11 +291,12 @@ function nominatimSearchResults(obj, requestId) {

function nominatimSearch(text, requestId, searchOptions, dispatch) {
axios.get("//nominatim.openstreetmap.org/search", {params: {
q: text,
addressdetails: 1,
polygon_geojson: 1,
limit: 20,
format: 'json'
'q': text,
'addressdetails': 1,
'polygon_geojson': 1,
'limit': 20,
'format': 'json',
'accept-language': LocaleUtils.lang()
}}).then(response => dispatch(nominatimSearchResults(response.data, requestId)));
}

Expand Down
12 changes: 12 additions & 0 deletions static/translations/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Vše",
"enablelayer": "",
"existinglayer": "",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/de-CH.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "Annehmlichkeit",
"boundary": "Grenze",
"building": "Gebäude",
"landuse": "Landnutzung",
"leisure": "Freizeit",
"place": "Ort",
"highway": "Autobahn",
"natural": "Natur",
"railway": "Eisenbahn",
"tourism": "Tourismus"
},
"all": "Alle",
"enablelayer": "Ebene einschalten",
"existinglayer": "Die Ebene existiert bereits in der Karte",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "Koordinaten",
"nominatim": {
"amenity": "Annehmlichkeit",
"boundary": "Grenze",
"building": "Gebäude",
"landuse": "Landnutzung",
"leisure": "Freizeit",
"place": "Ort",
"highway": "Autobahn",
"natural": "Natur",
"railway": "Eisenbahn",
"tourism": "Tourismus"
},
"all": "Alle",
"enablelayer": "Ebene einschalten",
"existinglayer": "Die Ebene existiert bereits in der Karte",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "Coordinates",
"nominatim": {
"amenity": "Amenity",
"boundary": "Boundary",
"building": "Building",
"landuse": "Land use",
"leisure": "Leisure",
"place": "Place",
"highway": "Highway",
"natural": "Natural",
"railway": "Railway",
"tourism": "Tourism"
},
"all": "All",
"enablelayer": "Enable layer",
"existinglayer": "The layer already exists in the map",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Todo",
"enablelayer": "Habilitar capa",
"existinglayer": "La capa ya existe en el mapa",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "Coordonnées",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Tous",
"enablelayer": "Activer la couche",
"existinglayer": "La couche existe déjà dans la carte",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "Coordinate",
"nominatim": {
"amenity": "Amenità",
"boundary": "Confine",
"building": "Costruzione",
"landuse": "Utilizzo terreno",
"leisure": "Svago",
"place": "Località",
"highway": "Autostrata",
"natural": "Natura",
"railway": "Ferrovia",
"tourism": "Turismo"
},
"all": "Tutti",
"enablelayer": "Attivare il livello",
"existinglayer": "Il livello esiste già nella mappa",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Wszystko",
"enablelayer": "Włącz warstwę",
"existinglayer": "",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Todos",
"enablelayer": "Ativar a camada",
"existinglayer": "A camada já existe no mapa",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Todos",
"enablelayer": "Ativar a camada",
"existinglayer": "A camada já existe no mapa",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/ro-RO.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "Coordonate",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Toate",
"enablelayer": "Activare strat",
"existinglayer": "Strat existent",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Всё",
"enablelayer": "",
"existinglayer": "",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "Koordinater",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "",
"enablelayer": "",
"existinglayer": "",
Expand Down
12 changes: 12 additions & 0 deletions static/translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
},
"search": {
"coordinates": "",
"nominatim": {
"amenity": "",
"boundary": "",
"building": "",
"landuse": "",
"leisure": "",
"place": "",
"highway": "",
"natural": "",
"railway": "",
"tourism": ""
},
"all": "Tümü",
"enablelayer": "Geçerli katman",
"existinglayer": "Katman zaten haritada mevcut",
Expand Down
12 changes: 11 additions & 1 deletion static/translations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
],
"extra_strings": [
"appmenu.items.ExternalLink",
"search.coordinates"
"search.coordinates",
"search.nominatim.amenity",
"search.nominatim.boundary",
"search.nominatim.building",
"search.nominatim.landuse",
"search.nominatim.leisure",
"search.nominatim.place",
"search.nominatim.highway",
"search.nominatim.natural",
"search.nominatim.railway",
"search.nominatim.tourism"
],
"overrides": [
"bottombar.viewertitle_label"
Expand Down

0 comments on commit 1e139a1

Please sign in to comment.