Commit c265dfba by Saleem Latif

Merge pull request #11390 from edx/saleem-latif/SOL-1529-translation-updates

Going to merge, "Remove concatenation of i18n strings."
parents 827dd1bd dc502ea9
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
invalidateCertificate: function() { invalidateCertificate: function() {
var user = this.$("#certificate-invalidation-user").val(); var user = this.$("#certificate-invalidation-user").val();
var notes = this.$("#certificate-invalidation-notes").val(); var notes = this.$("#certificate-invalidation-notes").val();
var message = "";
var certificate_invalidation = new CertificateInvalidationModel({ var certificate_invalidation = new CertificateInvalidationModel({
url: this.collection.url, url: this.collection.url,
...@@ -41,10 +42,8 @@ ...@@ -41,10 +42,8 @@
}); });
if (this.collection.findWhere({user: user})) { if (this.collection.findWhere({user: user})) {
this.showMessage( message = gettext("Certificate of <%= user %> has already been invalidated. Please check your spelling and retry."); // jshint ignore:line
gettext("Certificate of ") + user + this.escapeAndShowMessage(_.template(message, {user: user}));
gettext(" has already been invalidated. Please check your spelling and retry."
));
} }
else if (certificate_invalidation.isValid()) { else if (certificate_invalidation.isValid()) {
var self = this; var self = this;
...@@ -53,25 +52,26 @@ ...@@ -53,25 +52,26 @@
success: function(model) { success: function(model) {
self.collection.add(model); self.collection.add(model);
self.showMessage( message = gettext('Certificate has been successfully invalidated for <%= user %>.');
gettext('Certificate has been successfully invalidated for ') + user + '.' self.escapeAndShowMessage(_.template(message, {user: user}));
);
}, },
error: function(model, response) { error: function(model, response) {
try { try {
var response_data = JSON.parse(response.responseText); var response_data = JSON.parse(response.responseText);
self.showMessage(response_data.message); self.escapeAndShowMessage(response_data.message);
} }
catch(exception) { catch(exception) {
self.showMessage(gettext("Server Error, Please refresh the page and try again.")); self.escapeAndShowMessage(
gettext("Server Error, Please refresh the page and try again.")
);
} }
} }
}); });
} }
else { else {
this.showMessage(certificate_invalidation.validationError); this.escapeAndShowMessage(certificate_invalidation.validationError);
} }
}, },
...@@ -83,16 +83,19 @@ ...@@ -83,16 +83,19 @@
if (model) { if (model) {
model.destroy({ model.destroy({
success: function() { success: function() {
self.showMessage(gettext('The certificate for this learner has been re-validated and ' + self.escapeAndShowMessage(
'the system is re-running the grade for this learner.')); gettext('The certificate for this learner has been re-validated and the system is re-running the grade for this learner.') // jshint ignore:line
);
}, },
error: function(model, response) { error: function(model, response) {
try { try {
var response_data = JSON.parse(response.responseText); var response_data = JSON.parse(response.responseText);
self.showMessage(response_data.message); self.escapeAndShowMessage(response_data.message);
} }
catch(exception) { catch(exception) {
self.showMessage(gettext("Server Error, Please refresh the page and try again.")); self.escapeAndShowMessage(
gettext("Server Error, Please refresh the page and try again.")
);
} }
}, },
wait: true, wait: true,
...@@ -100,8 +103,9 @@ ...@@ -100,8 +103,9 @@
}); });
} }
else { else {
self.showMessage(gettext('Could not find Certificate Invalidation in the list. ' + self.escapeAndShowMessage(
'Please refresh the page and try again')); gettext('Could not find Certificate Invalidation in the list. Please refresh the page and try again') // jshint ignore:line
);
} }
}, },
...@@ -110,9 +114,9 @@ ...@@ -110,9 +114,9 @@
return re.test(email); return re.test(email);
}, },
showMessage: function(message) { escapeAndShowMessage: function(message) {
$(this.messages + ">p" ).remove(); $(this.messages + ">p" ).remove();
this.$(this.messages).removeClass('hidden').append("<p>"+ gettext(message) + "</p>"); this.$(this.messages).removeClass('hidden').append("<p>"+ _.escape(message) + "</p>");
} }
}); });
......
...@@ -54,7 +54,9 @@ ...@@ -54,7 +54,9 @@
model.destroy( model.destroy(
{ {
success: function() { success: function() {
self.showMessage('Student Removed from certificate white list successfully.'); self.escapeAndShowMessage(
gettext('Student Removed from certificate white list successfully.')
);
}, },
error: this.showError(this), error: this.showError(this),
wait: true, wait: true,
...@@ -63,9 +65,8 @@ ...@@ -63,9 +65,8 @@
); );
} }
else{ else{
this.showMessage( this.escapeAndShowMessage(
'Could not find Certificate Exception in white list. ' + gettext('Could not find Certificate Exception in white list. Please refresh the page and try again') // jshint ignore:line
'Please refresh the page and try again'
); );
} }
}, },
...@@ -77,15 +78,15 @@ ...@@ -77,15 +78,15 @@
); );
}, },
showMessage: function(message){ escapeAndShowMessage: function(message){
$(this.message_div + ">p" ).remove(); $(this.message_div + ">p" ).remove();
$(this.message_div).removeClass('hidden').append("<p>"+ gettext(message) + "</p>").focus(); $(this.message_div).removeClass('hidden').append("<p>"+ _.escape(message) + "</p>").focus();
$(this.message_div).fadeOut(6000, "linear"); $(this.message_div).fadeOut(6000, "linear");
}, },
showSuccess: function(caller_object){ showSuccess: function(caller_object){
return function(xhr){ return function(xhr){
caller_object.showMessage(xhr.message); caller_object.escapeAndShowMessage(xhr.message);
}; };
}, },
...@@ -93,11 +94,12 @@ ...@@ -93,11 +94,12 @@
return function(xhr){ return function(xhr){
try{ try{
var response = JSON.parse(xhr.responseText); var response = JSON.parse(xhr.responseText);
caller_object.showMessage(response.message); caller_object.escapeAndShowMessage(response.message);
} }
catch(exception){ catch(exception){
caller_object.showMessage( caller_object.escapeAndShowMessage(
"Server Error, Please refresh the page and try again."); gettext("Server Error, Please refresh the page and try again.")
);
} }
}; };
} }
......
...@@ -51,21 +51,23 @@ ...@@ -51,21 +51,23 @@
notes: notes, notes: notes,
new: true new: true
}); });
var message = "";
if(this.collection.findWhere(model)){ if(this.collection.findWhere(model)){
this.showMessage( message = gettext("<%= user %> already in exception list.");
(user_name || user_email) + " already in exception list." this.escapeAndShowMessage(
_.template(message, {user: (user_name || user_email)})
); );
} }
else if(certificate_exception.isValid()){ else if(certificate_exception.isValid()){
message = gettext("<%= user %> has been successfully added to the exception list. Click Generate Exception Certificate below to send the certificate."); // jshint ignore:line
certificate_exception.save( certificate_exception.save(
null, null,
{ {
success: this.showSuccess( success: this.showSuccess(
this, this,
true, true,
(user_name || user_email) + ' has been successfully added to the exception list.' + _.template(message, {user: (user_name || user_email)})
' Click Generate Exception Certificate below to send the certificate.'
), ),
error: this.showError(this) error: this.showError(this)
} }
...@@ -73,7 +75,7 @@ ...@@ -73,7 +75,7 @@
} }
else{ else{
this.showMessage(certificate_exception.validationError); this.escapeAndShowMessage(certificate_exception.validationError);
} }
}, },
...@@ -82,9 +84,9 @@ ...@@ -82,9 +84,9 @@
return re.test(email); return re.test(email);
}, },
showMessage: function(message){ escapeAndShowMessage: function(message){
$(this.message_div + ">p" ).remove(); $(this.message_div + ">p" ).remove();
this.$(this.message_div).removeClass('hidden').append("<p>"+ gettext(message) + "</p>"); this.$(this.message_div).removeClass('hidden').append("<p>"+ _.escape(message) + "</p>");
}, },
showSuccess: function(caller, add_model, message){ showSuccess: function(caller, add_model, message){
...@@ -92,7 +94,7 @@ ...@@ -92,7 +94,7 @@
if(add_model){ if(add_model){
caller.collection.add(model); caller.collection.add(model);
} }
caller.showMessage(message); caller.escapeAndShowMessage(message);
}; };
}, },
...@@ -100,11 +102,11 @@ ...@@ -100,11 +102,11 @@
return function(model, response){ return function(model, response){
try{ try{
var response_data = JSON.parse(response.responseText); var response_data = JSON.parse(response.responseText);
caller.showMessage(response_data.message); caller.escapeAndShowMessage(response_data.message);
} }
catch(exception){ catch(exception){
caller.showMessage("" + caller.escapeAndShowMessage(
"Server Error, Please refresh the page and try again." gettext("Server Error, Please refresh the page and try again.")
); );
} }
}; };
......
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