Switch to using i18n-js for handling translations in javascript
This commit is contained in:
parent
9638d6ea7f
commit
7ad58d1411
76 changed files with 552 additions and 563 deletions
|
@ -22,7 +22,7 @@ function createMap(divName, options) {
|
|||
theme: "<%= asset_path 'theme/openstreetmap/style.css' %>"
|
||||
});
|
||||
|
||||
var mapnik = new OpenLayers.Layer.OSM.Mapnik(i18n("javascripts.map.base.standard"), {
|
||||
var mapnik = new OpenLayers.Layer.OSM.Mapnik(I18n.t("javascripts.map.base.standard"), {
|
||||
attribution: "",
|
||||
keyid: "mapnik",
|
||||
displayOutsideMaxExtent: true,
|
||||
|
@ -31,7 +31,7 @@ function createMap(divName, options) {
|
|||
});
|
||||
map.addLayer(mapnik);
|
||||
|
||||
var cyclemap = new OpenLayers.Layer.OSM.CycleMap(i18n("javascripts.map.base.cycle_map"), {
|
||||
var cyclemap = new OpenLayers.Layer.OSM.CycleMap(I18n.t("javascripts.map.base.cycle_map"), {
|
||||
attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
|
||||
keyid: "cyclemap",
|
||||
displayOutsideMaxExtent: true,
|
||||
|
@ -40,7 +40,7 @@ function createMap(divName, options) {
|
|||
});
|
||||
map.addLayer(cyclemap);
|
||||
|
||||
var transportmap = new OpenLayers.Layer.OSM.TransportMap(i18n("javascripts.map.base.transport_map"), {
|
||||
var transportmap = new OpenLayers.Layer.OSM.TransportMap(I18n.t("javascripts.map.base.transport_map"), {
|
||||
attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
|
||||
keyid: "transportmap",
|
||||
displayOutsideMaxExtent: true,
|
||||
|
@ -49,7 +49,7 @@ function createMap(divName, options) {
|
|||
});
|
||||
map.addLayer(transportmap);
|
||||
|
||||
var mapquest = new OpenLayers.Layer.OSM(i18n("javascripts.map.base.mapquest"), [
|
||||
var mapquest = new OpenLayers.Layer.OSM(I18n.t("javascripts.map.base.mapquest"), [
|
||||
"http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
|
||||
"http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
|
||||
"http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
//= require jquery_ujs
|
||||
//= require jquery.autogrowtextarea
|
||||
//= require jquery.timers
|
||||
//= require i18n/translations
|
||||
|
||||
/*
|
||||
* Called as the user scrolls/zooms around to aniplate hrefs of the
|
||||
|
@ -50,11 +51,11 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
|
|||
$(link).off("click.minzoom");
|
||||
|
||||
if (zoom >= minzoom) {
|
||||
$(link).attr("title", i18n("javascripts.site." + name + "_tooltip"));
|
||||
$(link).attr("title", I18n.t("javascripts.site." + name + "_tooltip"));
|
||||
$(link).removeClass("disabled");
|
||||
} else {
|
||||
$(link).on("click.minzoom", function () { alert(i18n("javascripts.site." + name + "_zoom_alert")); return false; });
|
||||
$(link).attr("title", i18n("javascripts.site." + name + "_disabled_tooltip"));
|
||||
$(link).on("click.minzoom", function () { alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false; });
|
||||
$(link).attr("title", I18n.t("javascripts.site." + name + "_disabled_tooltip"));
|
||||
$(link).addClass("disabled");
|
||||
}
|
||||
}
|
||||
|
@ -144,26 +145,6 @@ function setArgs(url, args) {
|
|||
return url.replace(/\?.*$/, "") + "?" + queryitems.join("&");
|
||||
}
|
||||
|
||||
/*
|
||||
* Called to interpolate JavaScript variables in strings using a
|
||||
* similar syntax to rails I18n string interpolation - the only
|
||||
* difference is that [[foo]] is the placeholder syntax instead
|
||||
* of {{foo}} which allows the same string to be processed by both
|
||||
* rails and then later by javascript.
|
||||
*/
|
||||
function i18n(string, keys) {
|
||||
string = i18n_strings[string] || string;
|
||||
|
||||
for (var key in keys) {
|
||||
var re_key = '\\[\\[' + key + '\\]\\]';
|
||||
var re = new RegExp(re_key, "g");
|
||||
|
||||
string = string.replace(re, keys[key]);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called to interlace the bits in x and y, making a Morton code.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue