Commit ffce323b by Will Daly

Merge pull request #275 from edx/will/jsi18n

Extract JavaScript i18n strings
parents 0dff7333 a67835d7
......@@ -6,6 +6,12 @@ if (typeof OpenAssessment == "undefined" || !OpenAssessment) {
}
// Stub gettext if the runtime doesn't provide it
if (typeof window.gettext === 'undefined') {
window.gettext = function(text) { return text; };
}
/**
Interface for student-facing views.
......@@ -337,7 +343,7 @@ OpenAssessment.BaseView.prototype = {
var container = '#openassessment__' + step;
$(container).toggleClass('has--error', true);
$(container + ' .step__status__value i').removeClass().addClass('ico icon-warning-sign');
$(container + ' .step__status__value .copy').html('Unable to Load');
$(container + ' .step__status__value .copy').html(gettext('Unable to Load'));
},
/**
......
......@@ -6,6 +6,10 @@ if (typeof OpenAssessment == "undefined" || !OpenAssessment) {
OpenAssessment = {};
}
// Stub gettext if the runtime doesn't provide it
if (typeof window.gettext === 'undefined') {
window.gettext = function(text) { return text; };
}
/**
Interface for editing view in Studio.
......@@ -87,7 +91,7 @@ OpenAssessment.StudioView.prototype = {
executed if the user confirms the update.
**/
confirmPostReleaseUpdate: function(onConfirm) {
var msg = "This problem has already been released. Any changes will apply only to future assessments.";
var msg = gettext("This problem has already been released. Any changes will apply only to future assessments.");
// TODO: classier confirm dialog
if (confirm(msg)) { onConfirm(); }
},
......
......@@ -6,6 +6,12 @@ if (typeof OpenAssessment == "undefined" || !OpenAssessment) {
}
// Stub gettext if the runtime doesn't provide it
if (typeof window.gettext === 'undefined') {
window.gettext = function(text) { return text; };
}
/**
Interface for grade view.
......
......@@ -6,6 +6,12 @@ if (typeof OpenAssessment == "undefined" || !OpenAssessment) {
}
// Stub gettext if the runtime doesn't provide it
if (typeof window.gettext === 'undefined') {
window.gettext = function(text) { return text; };
}
/**
Interface for response (submission) view.
......@@ -141,7 +147,8 @@ OpenAssessment.ResponseView.prototype = {
} else {
// Setting the HTML will overwrite the screen reader tag,
// so prepend it to the message.
sel.html('<span class="sr">Status of Your Response:</span>\n' + msg);
var label = gettext("Status of Your Response");
sel.html('<span class="sr">' + label + ':' + '</span>\n' + msg);
}
},
......@@ -177,7 +184,7 @@ OpenAssessment.ResponseView.prototype = {
// Update the save button and status only if the response has changed
if ($.trim(this.savedResponse) !== currentResponse) {
this.saveEnabled(isBlank);
this.saveStatus('This response has not been saved.');
this.saveStatus(gettext('This response has not been saved.'));
}
},
......@@ -186,7 +193,7 @@ OpenAssessment.ResponseView.prototype = {
**/
save: function() {
// Update the save status and error notifications
this.saveStatus('Saving...');
this.saveStatus(gettext('Saving...'));
this.baseView.toggleActionError('save', null);
var view = this;
......@@ -201,10 +208,10 @@ OpenAssessment.ResponseView.prototype = {
view.submitEnabled(currentResponse !== '');
if (currentResponse == savedResponse) {
view.saveEnabled(false);
view.saveStatus("This response has been saved but not submitted.");
view.saveStatus(gettext("This response has been saved but not submitted."));
}
}).fail(function(errMsg) {
view.saveStatus('Error');
view.saveStatus(gettext('Error'));
view.baseView.toggleActionError('save', errMsg);
});
},
......
......@@ -6,6 +6,12 @@ if (typeof OpenAssessment == "undefined" || !OpenAssessment) {
}
// Stub gettext if the runtime doesn't provide it
if (typeof window.gettext === 'undefined') {
window.gettext = function(text) { return text; };
}
/**
Interface for server-side XBlock handlers.
......@@ -69,7 +75,7 @@ OpenAssessment.Server.prototype = {
}).done(function(data) {
defer.resolveWith(this, [data]);
}).fail(function(data) {
defer.rejectWith(this, ['This section could not be loaded.']);
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
});
}).promise();
},
......@@ -100,7 +106,7 @@ OpenAssessment.Server.prototype = {
}).done(function(data) {
defer.resolveWith(this, [data]);
}).fail(function(data) {
defer.rejectWith(this, ['This section could not be loaded.']);
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
});
}).promise();
},
......@@ -119,7 +125,8 @@ OpenAssessment.Server.prototype = {
var url = this.url('submit');
if (submission.length > this.maxInputSize) {
return $.Deferred(function(defer) {
defer.rejectWith(this, ["submit", "This response is too long. Please shorten the response and try to submit it again."]);
var errorMsg = gettext("This response is too long. Please shorten the response and try to submit it again.");
defer.rejectWith(this, ["submit", errorMsg]);
}).promise();
}
return $.Deferred(function(defer) {
......@@ -140,7 +147,7 @@ OpenAssessment.Server.prototype = {
defer.rejectWith(this, [errorNum, errorMsg]);
}
}).fail(function(data) {
defer.rejectWith(this, ["AJAX", "This response could not be submitted."]);
defer.rejectWith(this, ["AJAX", gettext("This response could not be submitted.")]);
});
}).promise();
},
......@@ -159,7 +166,8 @@ OpenAssessment.Server.prototype = {
var url = this.url('save_submission');
if (submission.length > this.maxInputSize) {
return $.Deferred(function(defer) {
defer.rejectWith(this, ["This response is too long. Please shorten the response and try to save it again."]);
var errorMsg = gettext("This response is too long. Please shorten the response and try to save it again.");
defer.rejectWith(this, [errorMsg]);
}).promise();
}
return $.Deferred(function(defer) {
......@@ -171,7 +179,7 @@ OpenAssessment.Server.prototype = {
if (data.success) { defer.resolve(); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
defer.rejectWith(this, ["This response could not be saved."]);
defer.rejectWith(this, [gettext("This response could not be saved.")]);
});
}).promise();
},
......@@ -199,7 +207,8 @@ OpenAssessment.Server.prototype = {
var url = this.url('submit_feedback');
if (text.length > this.maxInputSize) {
return $.Deferred(function(defer) {
defer.rejectWith(this, ["This feedback is too long. Please shorten your feedback and try to submit it again."]);
var errorMsg = gettext("This feedback is too long. Please shorten your feedback and try to submit it again.");
defer.rejectWith(this, [errorMsg]);
}).promise();
}
var payload = JSON.stringify({
......@@ -213,7 +222,7 @@ OpenAssessment.Server.prototype = {
else { defer.rejectWith(this, [data.msg]); }
}
).fail(function(data) {
defer.rejectWith(this, ['This feedback could not be submitted.']);
defer.rejectWith(this, [gettext('This feedback could not be submitted.')]);
});
}).promise();
},
......@@ -242,7 +251,8 @@ OpenAssessment.Server.prototype = {
var url = this.url('peer_assess');
if (feedback.length > this.maxInputSize) {
return $.Deferred(function(defer) {
defer.rejectWith(this, ["The comments on this assessment are too long. Please shorten your comments and try to submit them again."]);
var errorMsg = gettext("The comments on this assessment are too long. Please shorten your comments and try to submit them again.");
defer.rejectWith(this, [errorMsg]);
}).promise();
}
var payload = JSON.stringify({
......@@ -260,7 +270,7 @@ OpenAssessment.Server.prototype = {
}
}
).fail(function(data) {
defer.rejectWith(this, ['This assessment could not be submitted.']);
defer.rejectWith(this, [gettext('This assessment could not be submitted.')]);
});
}).promise();
},
......@@ -300,7 +310,7 @@ OpenAssessment.Server.prototype = {
}
}
).fail(function(data) {
defer.rejectWith(this, ['This assessment could not be submitted.']);
defer.rejectWith(this, [gettext('This assessment could not be submitted.')]);
});
});
},
......@@ -328,7 +338,7 @@ OpenAssessment.Server.prototype = {
if (data.success) { defer.resolveWith(this, [data.xml]); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
defer.rejectWith(this, ['This problem could not be loaded.']);
defer.rejectWith(this, [gettext('This problem could not be loaded.')]);
});
}).promise();
},
......@@ -357,7 +367,7 @@ OpenAssessment.Server.prototype = {
if (data.success) { defer.resolve(); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
defer.rejectWith(this, ['This problem could not be saved.']);
defer.rejectWith(this, [gettext('This problem could not be saved.')]);
});
}).promise();
},
......@@ -387,7 +397,7 @@ OpenAssessment.Server.prototype = {
if (data.success) { defer.resolveWith(this, [data.is_released]); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
defer.rejectWith(this, ["The server could not be contacted."]);
defer.rejectWith(this, [gettext("The server could not be contacted.")]);
});
}).promise();
}
......
# edX Internal Requirements
git+https://github.com/edx/XBlock.git@3b6e4218bd326f84dbeb0baed7b2b7813ffea3dd#egg=XBlock
git+https://github.com/edx/xblock-sdk.git@50ed1646d24f6f0a21d6d0bb074e3b7c8a78fd5a#egg=xblock-sdk
git+https://github.com/edx/xblock-sdk.git@4b312de38c037fda31c003e02240e3bd2f6a4628#egg=xblock-sdk
# Third Party Requirements
defusedxml==0.4.1
......
from django.conf import settings
from django.conf.urls import include, patterns, url
from django.views.i18n import javascript_catalog
from django.contrib import admin
import openassessment.assessment.urls
......@@ -8,6 +9,11 @@ import workbench.urls
admin.autodiscover()
# Packages to include in the JavaScript i18n strings
JS_INFO_DICT = {
'packages': ('openassessment.xblock',),
}
urlpatterns = patterns(
'',
# Django built-in
......@@ -19,6 +25,9 @@ urlpatterns = patterns(
# edx-ora2 apps
url(r'^submissions/', include(submissions.urls)),
url(r'^peer/evaluations/', include(openassessment.assessment.urls)),
# JavaScript i18n
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', JS_INFO_DICT),
)
# We need to do explicit setup of the Django debug toolbar because autodiscovery
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment