From 36a2569370943c3e4a6408b22368c70bfb5f603c Mon Sep 17 00:00:00 2001 From: Aleksander Chromik Date: Fri, 8 Oct 2021 16:42:50 +0200 Subject: [PATCH] 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 --- core/server/services/invites/index.js | 4 ++-- core/server/services/invites/invites.js | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/core/server/services/invites/index.js b/core/server/services/invites/index.js index 282e81d82f..ef1f4c3d3e 100644 --- a/core/server/services/invites/index.js +++ b/core/server/services/invites/index.js @@ -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 diff --git a/core/server/services/invites/invites.js b/core/server/services/invites/invites.js index 6977bd3314..72775ee228 100644 --- a/core/server/services/invites/invites.js +++ b/core/server/services/invites/invites.js @@ -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); }