[#21] Fix i18n calls
All the 'self' on the 'showError' function should be 'this', otherwise you will refer to the window. Also 'this.i18n' assumes an 'i18n' key in the module options. Looks like you are trying to pass some variables to the string template, note the sprintf-like syntax.
This commit is contained in:
parent
7bf2c609e6
commit
e4774e62a5
|
@ -8,6 +8,9 @@ ckan.module('geojsonpreview', function (jQuery, _) {
|
||||||
opacity: 0.7,
|
opacity: 0.7,
|
||||||
fillOpacity: 0.1,
|
fillOpacity: 0.1,
|
||||||
weight: 2
|
weight: 2
|
||||||
|
},
|
||||||
|
i18n: {
|
||||||
|
'error': _('An error occurred: %(text)s %(error)s')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
@ -58,15 +61,15 @@ ckan.module('geojsonpreview', function (jQuery, _) {
|
||||||
|
|
||||||
showError: function (jqXHR, textStatus, errorThrown) {
|
showError: function (jqXHR, textStatus, errorThrown) {
|
||||||
if (textStatus == 'error' && jqXHR.responseText.length) {
|
if (textStatus == 'error' && jqXHR.responseText.length) {
|
||||||
self.el.html(jqXHR.responseText);
|
this.el.html(jqXHR.responseText);
|
||||||
} else {
|
} else {
|
||||||
self.el.html(self.i18n('error', {text: textStatus, error: errorThrown}));
|
this.el.html(this.i18n('error', {text: textStatus, error: errorThrown}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showPreview: function (geojsonFeature) {
|
showPreview: function (geojsonFeature) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var gjLayer = L.geoJson(undefined, {
|
var gjLayer = L.geoJson(geojsonFeature, {
|
||||||
style: self.options.style,
|
style: self.options.style,
|
||||||
onEachFeature: function(feature, layer) {
|
onEachFeature: function(feature, layer) {
|
||||||
var body = '';
|
var body = '';
|
||||||
|
@ -80,7 +83,6 @@ ckan.module('geojsonpreview', function (jQuery, _) {
|
||||||
layer.bindPopup(popupContent);
|
layer.bindPopup(popupContent);
|
||||||
}
|
}
|
||||||
}).addTo(self.map);
|
}).addTo(self.map);
|
||||||
gjLayer.addData(geojsonFeature);
|
|
||||||
self.map.fitBounds(gjLayer.getBounds());
|
self.map.fitBounds(gjLayer.getBounds());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue