From 684721b1bd2883694ade20fbecc6a5ff6237d5ea Mon Sep 17 00:00:00 2001 From: PJ <43812132+pegjee@users.noreply.github.com> Date: Sat, 9 Oct 2021 01:21:22 +1100 Subject: [PATCH] Replaced i18n with tpl in accept.js (#13471) refs: #13380 - The i18n package is deprecated. It is being replaced with the tpl package. --- core/server/services/invitations/accept.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/server/services/invitations/accept.js b/core/server/services/invitations/accept.js index c1d6b1c13d..e30ab59296 100644 --- a/core/server/services/invitations/accept.js +++ b/core/server/services/invitations/accept.js @@ -1,7 +1,14 @@ const errors = require('@tryghost/errors'); -const i18n = require('../../../shared/i18n'); +const tpl = require('@tryghost/tpl'); const models = require('../../models'); const security = require('@tryghost/security'); +const messages = {inviteNotFound: 'Invite not found.', + inviteExpired: 'Invite is expired.', + inviteEmailAlreadyExist: { + message: 'Could not create an account, email is already in use.', + context: 'Attempting to create an account with existing email address.', + help: 'Use different email address to register your account.' + }}; async function accept(invitation) { const data = invitation.invitation[0]; @@ -11,19 +18,19 @@ async function accept(invitation) { let invite = await models.Invite.findOne({token: inviteToken, status: 'sent'}, options); if (!invite) { - throw new errors.NotFoundError({message: i18n.t('errors.api.invites.inviteNotFound')}); + throw new errors.NotFoundError({message: tpl(messages.inviteNotFound)}); } if (invite.get('expires') < Date.now()) { - throw new errors.NotFoundError({message: i18n.t('errors.api.invites.inviteExpired')}); + throw new errors.NotFoundError({message: tpl(messages.inviteExpired)}); } let user = await models.User.findOne({email: data.email}); if (user) { throw new errors.ValidationError({ - message: i18n.t('errors.api.invites.inviteEmailAlreadyExist.message'), - context: i18n.t('errors.api.invites.inviteEmailAlreadyExist.context'), - help: i18n.t('errors.api.invites.inviteEmailAlreadyExist.help') + message: tpl(messages.inviteEmailAlreadyExist.message), + context: tpl(messages.inviteEmailAlreadyExist.context), + help: tpl(messages.inviteEmailAlreadyExist.help) }); }