Fix translations to be injected at config time

This commit is contained in:
Tautvidas Sipavičius
2016-03-07 17:52:14 +02:00
parent b2682fa0b7
commit f688a69f8b
8 changed files with 30 additions and 18 deletions

View File

@ -83,7 +83,7 @@ define([
that.get('_container').get('blocks').reset(content, {parse: true});
that.trigger('postsChanged');
}).fail(function(error) {
MailPoet.Notice(MailPoetI18n.failedToFetchRenderedPosts);
MailPoet.Notice.error(App.getConfig().get('translations.failedToFetchRenderedPosts'));
});
},
/**

View File

@ -79,7 +79,7 @@ define([
},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: MailPoetI18n.customFieldsWindowTitle,
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
});
},
});

View File

@ -79,7 +79,7 @@ define([
},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: MailPoetI18n.customFieldsWindowTitle,
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
});
},
});

View File

@ -101,7 +101,7 @@ define([
that.get('_selectedPosts').reset(); // Empty out the collection
that.trigger('change:_availablePosts');
}).fail(function() {
MailPoet.Notice(MailPoetI18n.failedToFetchAvailablePosts);
MailPoet.Notice.error(App.getConfig().get('translations.failedToFetchAvailablePosts'));
});
},
_refreshTransformedPosts: function() {
@ -118,7 +118,7 @@ define([
CommunicationComponent.getTransformedPosts(data).done(function(posts) {
that.get('_transformedPosts').get('blocks').reset(posts, {parse: true});
}).fail(function() {
MailPoet.Notice(MailPoetI18n.failedToFetchRenderedPosts);
MailPoet.Notice.error(App.getConfig().get('translations.failedToFetchRenderedPosts'));
});
},
_insertSelectedPosts: function() {
@ -134,7 +134,7 @@ define([
CommunicationComponent.getTransformedPosts(data).done(function(posts) {
collection.add(posts, { at: index });
}).fail(function() {
MailPoet.Notice(MailPoetI18n.failedToFetchRenderedPosts);
MailPoet.Notice.error(App.getConfig().get('translations.failedToFetchRenderedPosts'));
});
},
});

View File

@ -77,7 +77,7 @@ define([
},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: MailPoetI18n.customFieldsWindowTitle,
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
});
}
},

View File

@ -191,7 +191,7 @@ define([
if (templateName === '') {
MailPoet.Notice.error(
MailPoetI18n.templateNameMissing,
App.getConfig().get('translations.templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
@ -199,7 +199,7 @@ define([
);
} else if (templateDescription === '') {
MailPoet.Notice.error(
MailPoetI18n.templateDescriptionMissing,
App.getConfig().get('translations.templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
@ -211,7 +211,7 @@ define([
description: templateDescription,
}).done(function() {
MailPoet.Notice.success(
MailPoetI18n.templateSaved,
App.getConfig().get('translations.templateSaved'),
{
positionAfter: that.$el,
scroll: true,
@ -219,7 +219,7 @@ define([
);
}).fail(function() {
MailPoet.Notice.error(
MailPoetI18n.templateSaveFailed,
App.getConfig().get('translations.templateSaveFailed'),
{
positionAfter: that.$el,
scroll: true,
@ -244,7 +244,7 @@ define([
if (templateName === '') {
MailPoet.Notice.error(
MailPoetI18n.templateNameMissing,
App.getConfig().get('translations.templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
@ -252,7 +252,7 @@ define([
);
} else if (templateDescription === '') {
MailPoet.Notice.error(
MailPoetI18n.templateDescriptionMissing,
App.getConfig().get('translations.templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
@ -285,7 +285,7 @@ define([
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
JSON.stringify(jsonObject).indexOf("[unsubscribeUrl]") < 0) {
this.showValidationError(MailPoetI18n.unsubscribeLinkMissing);
this.showValidationError(App.getConfig().get('translations.unsubscribeLinkMissing'));
return;
}

View File

@ -1,13 +1,24 @@
define([
'newsletter_editor/App',
'newsletter_editor/components/communication',
'mailpoet',
'backbone',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery',
'sticky-kit'
], function(App, CommunicationComponent, Backbone, Marionette, SuperModel, _, jQuery, StickyKit) {
], function(
App,
CommunicationComponent,
MailPoet,
Backbone,
Marionette,
SuperModel,
_,
jQuery,
StickyKit
) {
"use strict";
@ -254,7 +265,7 @@ define([
if (data.subscriber.length <= 0) {
MailPoet.Notice.error(
MailPoetI18n.newsletterPreviewEmailMissing,
App.getConfig().get('translations.newsletterPreviewEmailMissing'),
{
positionAfter: $emailField,
scroll: true,
@ -268,7 +279,7 @@ define([
CommunicationComponent.previewNewsletter(data).done(function(response) {
if(response.result !== undefined && response.result === true) {
MailPoet.Notice.success(MailPoetI18n.newsletterPreviewSent, { scroll: true });
MailPoet.Notice.success(App.getConfig().get('translations.newsletterPreviewSent'), { scroll: true });
} else {
if (_.isArray(response.errors)) {
response.errors.map(function(error) {
@ -276,7 +287,7 @@ define([
});
} else {
MailPoet.Notice.error(
MailPoetI18n.newsletterPreviewFailedToSend,
App.getConfig().get('translations.newsletterPreviewFailedToSend'),
{
scroll: true,
static: true,