From d24cba4345d1784780c6036837109380e37986ae Mon Sep 17 00:00:00 2001 From: Kai Krueger Date: Sat, 29 Mar 2014 16:47:42 -0600 Subject: [PATCH] Minor fixes to the I18n code of routing MapQuest instructions still don't translate, as that backend doesn't accept simple language locals but require country codes as well. --- app/assets/javascripts/routing.js.erb | 2 +- .../javascripts/routing_engines/graphhopper.js | 4 +++- app/assets/javascripts/routing_engines/mapquest.js | 4 ++-- app/assets/javascripts/routing_engines/osrm.js | 2 +- config/locales/de.yml | 14 +++++++++++--- config/locales/en.yml | 1 + 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/routing.js.erb b/app/assets/javascripts/routing.js.erb index 84bf17832..3f38beef4 100644 --- a/app/assets/javascripts/routing.js.erb +++ b/app/assets/javascripts/routing.js.erb @@ -216,7 +216,7 @@ OSM.Routing=function(map,name,jqSearch) { $('#turnbyturn').append(row); cumulative+=step[3]; } - $('#sidebar_content').append('

' + r.chosenEngine.creditline + '

'); + $('#sidebar_content').append('

' + I18n.t('javascripts.directions.instructions.courtesy',{link: r.chosenEngine.creditline}) + '

'); }; r.clickTurn=function(instruction,latlng) { diff --git a/app/assets/javascripts/routing_engines/graphhopper.js b/app/assets/javascripts/routing_engines/graphhopper.js index 6d83e26e2..0f29c162b 100644 --- a/app/assets/javascripts/routing_engines/graphhopper.js +++ b/app/assets/javascripts/routing_engines/graphhopper.js @@ -1,6 +1,7 @@ GraphHopperEngine = function(vehicleName, vehicleParam, locale) { this.vehicleName = vehicleName; this.vehicleParam = vehicleParam; + //At this point the local system isn't correctly initialised yet, so we don't have accurate information about current locale this.locale = locale; if (!locale) this.locale = "en"; @@ -10,12 +11,13 @@ GraphHopperEngine.prototype.createConfig = function() { var that = this; return { name: "javascripts.directions.engines.graphhopper_"+this.vehicleName.toLowerCase(), + creditline: 'Graphhopper', draggable: false, _hints: {}, getRoute: function(isFinal, points) { var url = "http://graphhopper.com/routing/api/route?" + that.vehicleParam - + "&locale=" + that.locale; + + "&locale=" + I18n.currentLocale(); for (var i = 0; i < points.length; i++) { var pair = points[i].join(','); url += "&point=" + pair; diff --git a/app/assets/javascripts/routing_engines/mapquest.js b/app/assets/javascripts/routing_engines/mapquest.js index dc854ccdc..39e47706a 100644 --- a/app/assets/javascripts/routing_engines/mapquest.js +++ b/app/assets/javascripts/routing_engines/mapquest.js @@ -15,7 +15,7 @@ MapQuestEngine.prototype.createConfig = function() { var that = this; return { name: "javascripts.directions.engines.mapquest_"+this.vehicleName.toLowerCase(), - creditline: 'Directions courtesy of MapQuest ', + creditline: 'MapQuest ', draggable: false, _hints: {}, MQ_SPRITE_MAP: { @@ -45,7 +45,7 @@ MapQuestEngine.prototype.createConfig = function() { url+="&from="+from.join(','); url+="&to="+to.join(','); url+="&"+that.vehicleParam; - //url+="&locale=" + I18n.currentLocale(); //Doesn't actually work. MapQuest requires full locale e.g. "de_DE", but I18n only provides language, e.g. "de" + //url+="&locale=" + I18n.currentLocale(); //Doesn't actually work. MapQuest requires full locale e.g. "de_DE", but I18n may only provides language, e.g. "de" url+="&manMaps=false"; url+="&shapeFormat=raw&generalize=0&unit=k"; this.requestCORS(url); diff --git a/app/assets/javascripts/routing_engines/osrm.js b/app/assets/javascripts/routing_engines/osrm.js index 660a306ea..b40d5b306 100644 --- a/app/assets/javascripts/routing_engines/osrm.js +++ b/app/assets/javascripts/routing_engines/osrm.js @@ -13,7 +13,7 @@ OSRMEngine.prototype.createConfig = function() { var that = this; return { name: "javascripts.directions.engines.osrm_"+this.vehicleName.toLowerCase(), - creditline: 'Directions courtesy of OSRM', + creditline: 'OSRM', draggable: true, _hints: {}, getRoute: function(isFinal,points) { diff --git a/config/locales/de.yml b/config/locales/de.yml index d2d9e9349..798105ee0 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -944,10 +944,17 @@ de: directions: directions: "Fahranweisungen: " engines: - graphhopper_bike: "Fahrrad (GraphHopper)" - mapquest_bike: "Fahrrad (MapQuest)" + graphhopper_bicycle: "Fahrrad (GraphHopper)" + graphhopper_foot: "Fuss (GraphHopper)" + mapquest_bicycle: "Fahrrad (MapQuest)" + mapquest_foot: "Fuss (MapQuest)" + mapquest_car: "Auto (MapQuest)" osrm_car: "Auto (OSRM)" - cloudmade_foot: "Fuss (Cloudmade)" + distance: "Distanz:" + time: "Zeit:" + errors: + no_route: "Wir konnten keine Strecke zwischen diesen beiden Orten berechnen." + no_place: "Wir konnten den Ort nicht finden." instructions: continue_on: "Weiter auf " slight_right: "Rechts halten auf " @@ -967,6 +974,7 @@ de: against_oneway: "Go against one-way on " end_oneway: "Ende der Einbahnstrasse " unnamed: "(unbekannt)" + courtesy: "Fahranweisungen stammen von %{link}" key: title: Legende tooltip: Legende diff --git a/config/locales/en.yml b/config/locales/en.yml index 4384fda86..7787fde86 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2151,6 +2151,7 @@ en: against_oneway: "Go against one-way on " end_oneway: "End of one-way on " unnamed: "(unnamed)" + courtesy: "Directions courtesy of %{link}" time: "Time" redaction: edit: -- 2.43.2