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.
This commit is contained in:
Kai Krueger 2014-03-29 16:47:42 -06:00
parent 23ffdadb56
commit d24cba4345
6 changed files with 19 additions and 8 deletions

View file

@ -216,7 +216,7 @@ OSM.Routing=function(map,name,jqSearch) {
$('#turnbyturn').append(row); $('#turnbyturn').append(row);
cumulative+=step[3]; cumulative+=step[3];
} }
$('#sidebar_content').append('<p id="routing_credit">' + r.chosenEngine.creditline + '</p>'); $('#sidebar_content').append('<p id="routing_credit">' + I18n.t('javascripts.directions.instructions.courtesy',{link: r.chosenEngine.creditline}) + '</p>');
}; };
r.clickTurn=function(instruction,latlng) { r.clickTurn=function(instruction,latlng) {

View file

@ -1,6 +1,7 @@
GraphHopperEngine = function(vehicleName, vehicleParam, locale) { GraphHopperEngine = function(vehicleName, vehicleParam, locale) {
this.vehicleName = vehicleName; this.vehicleName = vehicleName;
this.vehicleParam = vehicleParam; 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; this.locale = locale;
if (!locale) if (!locale)
this.locale = "en"; this.locale = "en";
@ -10,12 +11,13 @@ GraphHopperEngine.prototype.createConfig = function() {
var that = this; var that = this;
return { return {
name: "javascripts.directions.engines.graphhopper_"+this.vehicleName.toLowerCase(), name: "javascripts.directions.engines.graphhopper_"+this.vehicleName.toLowerCase(),
creditline: '<a href="http://graphhopper.com/" target="_blank">Graphhopper</a>',
draggable: false, draggable: false,
_hints: {}, _hints: {},
getRoute: function(isFinal, points) { getRoute: function(isFinal, points) {
var url = "http://graphhopper.com/routing/api/route?" var url = "http://graphhopper.com/routing/api/route?"
+ that.vehicleParam + that.vehicleParam
+ "&locale=" + that.locale; + "&locale=" + I18n.currentLocale();
for (var i = 0; i < points.length; i++) { for (var i = 0; i < points.length; i++) {
var pair = points[i].join(','); var pair = points[i].join(',');
url += "&point=" + pair; url += "&point=" + pair;

View file

@ -15,7 +15,7 @@ MapQuestEngine.prototype.createConfig = function() {
var that = this; var that = this;
return { return {
name: "javascripts.directions.engines.mapquest_"+this.vehicleName.toLowerCase(), name: "javascripts.directions.engines.mapquest_"+this.vehicleName.toLowerCase(),
creditline: 'Directions courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">', creditline: '<a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">',
draggable: false, draggable: false,
_hints: {}, _hints: {},
MQ_SPRITE_MAP: { MQ_SPRITE_MAP: {
@ -45,7 +45,7 @@ MapQuestEngine.prototype.createConfig = function() {
url+="&from="+from.join(','); url+="&from="+from.join(',');
url+="&to="+to.join(','); url+="&to="+to.join(',');
url+="&"+that.vehicleParam; 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+="&manMaps=false";
url+="&shapeFormat=raw&generalize=0&unit=k"; url+="&shapeFormat=raw&generalize=0&unit=k";
this.requestCORS(url); this.requestCORS(url);

View file

@ -13,7 +13,7 @@ OSRMEngine.prototype.createConfig = function() {
var that = this; var that = this;
return { return {
name: "javascripts.directions.engines.osrm_"+this.vehicleName.toLowerCase(), name: "javascripts.directions.engines.osrm_"+this.vehicleName.toLowerCase(),
creditline: 'Directions courtesy of <a href="http://project-osrm.org/" target="_blank">OSRM</a>', creditline: '<a href="http://project-osrm.org/" target="_blank">OSRM</a>',
draggable: true, draggable: true,
_hints: {}, _hints: {},
getRoute: function(isFinal,points) { getRoute: function(isFinal,points) {

View file

@ -944,10 +944,17 @@ de:
directions: directions:
directions: "Fahranweisungen: " directions: "Fahranweisungen: "
engines: engines:
graphhopper_bike: "Fahrrad (GraphHopper)" graphhopper_bicycle: "Fahrrad (GraphHopper)"
mapquest_bike: "Fahrrad (MapQuest)" graphhopper_foot: "Fuss (GraphHopper)"
mapquest_bicycle: "Fahrrad (MapQuest)"
mapquest_foot: "Fuss (MapQuest)"
mapquest_car: "Auto (MapQuest)"
osrm_car: "Auto (OSRM)" 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: instructions:
continue_on: "Weiter auf " continue_on: "Weiter auf "
slight_right: "Rechts halten auf " slight_right: "Rechts halten auf "
@ -967,6 +974,7 @@ de:
against_oneway: "Go against one-way on " against_oneway: "Go against one-way on "
end_oneway: "Ende der Einbahnstrasse " end_oneway: "Ende der Einbahnstrasse "
unnamed: "(unbekannt)" unnamed: "(unbekannt)"
courtesy: "Fahranweisungen stammen von %{link}"
key: key:
title: Legende title: Legende
tooltip: Legende tooltip: Legende

View file

@ -2151,6 +2151,7 @@ en:
against_oneway: "Go against one-way on " against_oneway: "Go against one-way on "
end_oneway: "End of one-way on " end_oneway: "End of one-way on "
unnamed: "(unnamed)" unnamed: "(unnamed)"
courtesy: "Directions courtesy of %{link}"
time: "Time" time: "Time"
redaction: redaction:
edit: edit: