diff --git a/assets/js/src/ajax.js b/assets/js/src/ajax.js index 24c5bf7ff8..ed0994528f 100644 --- a/assets/js/src/ajax.js +++ b/assets/js/src/ajax.js @@ -1,9 +1,8 @@ -function requestFailed(xhr) { +function requestFailed(errorMessage, xhr) { if (xhr.responseJSON) { return xhr.responseJSON; } - var message = "An error has happened while performing a request, the server has responded with response code " - + xhr.status; + var message = errorMessage.replace("%d", xhr.status); return { errors: [ { @@ -75,7 +74,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, 'json' ).then(function(data) { return data; - }, requestFailed); + }, _.partial(requestFailed, MailPoet.I18n.t('ajaxFailedErrorMessage'))); // clear options this.options = {}; diff --git a/views/layout.html b/views/layout.html index 056cfa588d..c4884a9832 100644 --- a/views/layout.html +++ b/views/layout.html @@ -55,6 +55,9 @@ jQuery('.toplevel_page_mailpoet-newsletters.menu-top-last') 'mailpoet.js' )%> +<%= localize({ + 'ajaxFailedErrorMessage': __('An error has happened while performing a request, the server has responded with response code %d'), +}) %> <% block translations %><% endblock %> <% block after_translations %><% endblock %>