[ckan-changes] [okfn/ckan] 298bba: Localised missing strings in application.js
GitHub
noreply at github.com
Thu May 3 10:32:23 UTC 2012
Branch: refs/heads/feature-javascript-localisation
Home: https://github.com/okfn/ckan
Commit: 298bbad2109d03892ba8f65f1066d899e021f5ae
https://github.com/okfn/ckan/commit/298bbad2109d03892ba8f65f1066d899e021f5ae
Author: Aron Carroll <self at aroncarroll.com>
Date: 2012-05-03 (Thu, 03 May 2012)
Changed paths:
M ckan/public/scripts/application.js
M ckan/templates/js_strings.html
Log Message:
-----------
Localised missing strings in application.js
diff --git a/ckan/public/scripts/application.js b/ckan/public/scripts/application.js
index 6e00004..d1a9d7c 100644
--- a/ckan/public/scripts/application.js
+++ b/ckan/public/scripts/application.js
@@ -819,7 +819,7 @@ CKAN.View.ResourceAddUpload = Backbone.View.extend({
uploadFile: function(e) {
e.preventDefault();
if (!this.fileData) {
- alert('No file selected');
+ alert(CKAN.Strings.storageNoFile);
return;
}
var jqXHR = this.fileData.submit();
@@ -853,8 +853,7 @@ CKAN.View.ResourceAddUpload = Backbone.View.extend({
}
, {
error: function(model, error) {
- var msg = 'Filed uploaded OK but error adding resource: ' + error + '.';
- msg += 'You may need to create a resource directly. Uploaded file at: ' + data._location;
+ var msg = CKAN.Strings.storageError.replace('%error%', error).replace('%location%', data._location);
self.setMessage(msg, 'error');
}
}
@@ -1159,7 +1158,11 @@ CKAN.Utils = function($, my) {
my.relatedSetup = function(form) {
$('[rel=popover]').popover();
- function addAlert(msg) {
+ function addAlert(title, message) {
+ var msg = _.template('<strong><%= title %></strong> <%= msg %>', {
+ title: title,
+ msg: message
+ });
$('<div class="alert alert-error" />').html(msg).hide().prependTo(form).fadeIn();
}
@@ -1172,7 +1175,7 @@ CKAN.Utils = function($, my) {
data: data ? JSON.stringify(data) : undefined,
error: function(err, txt, w) {
// This needs to be far more informative.
- addAlert('<strong>Error:</strong> Unable to ' + action + ' related item');
+ addAlert(CKAN.Strings.error, CKAN.Strings.relatedError.replace('%action%', action));
}
});
}
@@ -1241,7 +1244,8 @@ CKAN.Utils = function($, my) {
event.preventDefault();
// Validate the form
- var form = $(this), data = {};
+ var form = $(this), data = {}, message;
+
jQuery.each(form.serializeArray(), function () {
data[this.name] = this.value;
});
@@ -1249,12 +1253,12 @@ CKAN.Utils = function($, my) {
form.find('.alert').remove();
form.find('.error').removeClass('error');
if (!data.title) {
- addAlert('<strong>Missing field:</strong> A title is required');
+ addAlert(CKAN.Strings.missingField, CKAN.Strings.requiredField.replace('%field%', 'title'));
$('[name=title]').parent().addClass('error');
return;
}
if (!data.url) {
- addAlert('<strong>Missing field:</strong> A url is required');
+ addAlert(CKAN.Strings.missingField, CKAN.Strings.requiredField.replace('%field%', 'url'));
$('[name=url]').parent().addClass('error');
return;
}
@@ -1422,10 +1426,11 @@ CKAN.DataPreview = function ($, my) {
// then passes the constructed Dataset, the constructed View, and the
// reclineState into the DataExplorer constructor.
my.loadEmbeddedPreview = function(resourceData, reclineState) {
- my.$dialog.html('<h4>Loading ... <img src="http://assets.okfn.org/images/icons/ajaxload-circle.gif" class="loading-spinner" /></h4>');
-
// Restore the Dataset from the given reclineState.
- var dataset = recline.Model.Dataset.restore(reclineState);
+ var dataset = recline.Model.Dataset.restore(reclineState),
+ lang = CKAN.Strings;
+
+ my.$dialog.html('<h4>' + lang.loading + ' <img src="http://assets.okfn.org/images/icons/ajaxload-circle.gif" class="loading-spinner" /></h4>');
// Only create the view defined in reclineState.currentView.
// TODO: tidy this up.
@@ -1433,7 +1438,7 @@ CKAN.DataPreview = function ($, my) {
if (reclineState.currentView === 'grid') {
views = [ {
id: 'grid',
- label: 'Grid',
+ label: lang.grid,
view: new recline.View.Grid({
model: dataset,
state: reclineState['view-grid']
@@ -1442,7 +1447,7 @@ CKAN.DataPreview = function ($, my) {
} else if (reclineState.currentView === 'graph') {
views = [ {
id: 'graph',
- label: 'Graph',
+ label: lang.graph,
view: new recline.View.Graph({
model: dataset,
state: reclineState['view-graph']
@@ -1451,7 +1456,7 @@ CKAN.DataPreview = function ($, my) {
} else if (reclineState.currentView === 'map') {
views = [ {
id: 'map',
- label: 'Map',
+ label: lang.map,
view: new recline.View.Map({
model: dataset,
state: reclineState['view-map']
@@ -1500,27 +1505,28 @@ CKAN.DataPreview = function ($, my) {
//
// Returns nothing.
my.loadPreviewDialog = function(resourceData) {
- my.$dialog.html('<h4>Loading ... <img src="http://assets.okfn.org/images/icons/ajaxload-circle.gif" class="loading-spinner" /></h4>');
+ var lang = CKAN.Strings;
+ my.$dialog.html('<h4>' + lang.loading + ' ... <img src="http://assets.okfn.org/images/icons/ajaxload-circle.gif" class="loading-spinner" /></h4>');
function initializeDataExplorer(dataset) {
var views = [
{
id: 'grid',
- label: 'Grid',
+ label: lang.grid,
view: new recline.View.Grid({
model: dataset
})
},
{
id: 'graph',
- label: 'Graph',
+ label: lang.graph,
view: new recline.View.Graph({
model: dataset
})
},
{
id: 'map',
- label: 'Map',
+ label: lang.map,
view: new recline.View.Map({
model: dataset
})
@@ -1688,8 +1694,8 @@ CKAN.DataPreview = function ($, my) {
var timer = setTimeout(function error() {
callback({
error: {
- title: 'Request Error',
- message: 'Dataproxy server did not respond after ' + (timeout / 1000) + ' seconds'
+ title: CKAN.Strings.dataProxyGetResourceErrorTitle,
+ message: CKAN.Strings.dataProxyGetResourceErrorMessage.replace('%seconds%', timeout / 1000)
}
});
}, timeout);
diff --git a/ckan/templates/js_strings.html b/ckan/templates/js_strings.html
index 1b757bb..eadb295 100644
--- a/ckan/templates/js_strings.html
+++ b/ckan/templates/js_strings.html
@@ -39,7 +39,6 @@
documentation = _('Documentation'),
code = _('Code'),
example = _('Example'),
-
upload = _('Upload'),
cancel = _('Cancel'),
name = _('Name'),
@@ -60,14 +59,25 @@
edit = _('Edit'),
preview = _('Preview'),
resourceFormatPlaceholder = _('e.g. csv, html, xls, rdf, ...'),
+ grid = _('Grid'),
+ graph = _('Graph'),
+ map = _('Map'),
+ error = _('Error:'),
unknown = _('Unknown'),
+ requiredField = _('A %field% is required'),
+ missingField = _('Missing Field'),
extraFields = _('Extra Fields'),
addExtraField = _('Add Extra Field'),
deleteResource = _('Delete Resource'),
youCanUseMarkdown = _('You can use %aMarkdown formatting%b here.'),
shouldADataStoreBeEnabled = _('Should a %aDataStore table and Data API%b be enabled for this resource?'),
datesAreInISO = _('Dates are in %aISO Format%b — eg. %c2012-12-25%d or %c2010-05-31T14:30%d.'),
- dataFileUploaded = _('Data File (Uploaded)')
+ dataFileUploaded = _('Data File (Uploaded)'),
+ dataProxyGetResourceErrorTitle = _('Request Error'),
+ dataProxyGetResourceErrorMessage = _('Dataproxy server did not respond after %seconds% seconds'),
+ relatedError = _('Unable to %action% related item'),
+ storageError = _('Filed uploaded OK but error adding resource: %error%. You may need to create a resource directly. Uploaded file at: %location%'),
+ storageNoFile = _('No file selected'),
), indent=4)}
</script>
================================================================
More information about the ckan-changes
mailing list