From 2f6fe8c8040ec067d2a7a5bdac772dc54f1637c3 Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Thu, 22 Jun 2017 16:47:36 +0100 Subject: [PATCH] Translate error message [MAILPOET-929] --- assets/js/src/ajax.js | 7 +++---- views/layout.html | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) 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 %>