Replaced i18n.t w/ tpl in class Invites (#13506)

refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
This commit is contained in:
Aleksander Chromik 2021-10-08 16:42:50 +02:00 committed by GitHub
parent 1ceab9dea3
commit 36a2569370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -1,5 +1,5 @@
const settingsCache = require('../../../shared/settings-cache');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const mailService = require('../../services/mail');
const logging = require('@tryghost/logging');
const urlUtils = require('../../../shared/url-utils');
@ -7,7 +7,7 @@ const Invites = require('./invites');
module.exports = new Invites({
settingsCache,
i18n,
tpl,
logging,
mailService,
urlUtils

View File

@ -1,9 +1,17 @@
const security = require('@tryghost/security');
const messages = {
invitedByName: '{invitedByName} has invited you to join {blogName}',
errorSendingEmail: {
error: 'Error sending email: {message}',
help: 'Please check your email settings and resend the invitation.'
}
};
class Invites {
constructor({settingsCache, i18n, logging, mailService, urlUtils}) {
constructor({settingsCache, tpl, logging, mailService, urlUtils}) {
this.settingsCache = settingsCache;
this.i18n = i18n;
this.tpl = tpl;
this.logging = logging;
this.mailService = mailService;
this.urlUtils = urlUtils;
@ -44,7 +52,7 @@ class Invites {
mail: [{
message: {
to: invite.get('email'),
subject: this.i18n.t('common.api.users.mail.invitedByName', {
subject: this.tpl(messages.invitedByName, {
invitedByName: emailData.invitedByName,
blogName: emailData.blogName
}),
@ -67,10 +75,10 @@ class Invites {
})
.catch((err) => {
if (err && err.errorType === 'EmailError') {
const errorMessage = this.i18n.t('errors.api.invites.errorSendingEmail.error', {
const errorMessage = this.tpl(messages.errorSendingEmail.error, {
message: err.message
});
const helpText = this.i18n.t('errors.api.invites.errorSendingEmail.help');
const helpText = this.tpl(messages.errorSendingEmail.help);
err.message = `${errorMessage} ${helpText}`;
this.logging.warn(err.message);
}