Translate error message

[MAILPOET-929]
This commit is contained in:
Pavel Dohnal
2017-06-22 16:47:36 +01:00
parent ec3e88e658
commit 2f6fe8c804
2 changed files with 6 additions and 4 deletions

View File

@@ -1,9 +1,8 @@
function requestFailed(xhr) { function requestFailed(errorMessage, xhr) {
if (xhr.responseJSON) { if (xhr.responseJSON) {
return xhr.responseJSON; return xhr.responseJSON;
} }
var message = "An error has happened while performing a request, the server has responded with response code " var message = errorMessage.replace("%d", xhr.status);
+ xhr.status;
return { return {
errors: [ errors: [
{ {
@@ -75,7 +74,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
'json' 'json'
).then(function(data) { ).then(function(data) {
return data; return data;
}, requestFailed); }, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage')));
// clear options // clear options
this.options = {}; this.options = {};

View File

@@ -55,6 +55,9 @@ jQuery('.toplevel_page_mailpoet-newsletters.menu-top-last')
'mailpoet.js' 'mailpoet.js'
)%> )%>
<%= localize({
'ajaxFailedErrorMessage': __('An error has happened while performing a request, the server has responded with response code %d'),
}) %>
<% block translations %><% endblock %> <% block translations %><% endblock %>
<% block after_translations %><% endblock %> <% block after_translations %><% endblock %>