From 548e83d665c77b82f71d0936b02f6f212f4464df Mon Sep 17 00:00:00 2001 From: Kenneth Fitzgerald <68879394+fitzgeraldkd@users.noreply.github.com> Date: Fri, 1 Oct 2021 14:00:03 -0400 Subject: [PATCH] Replaced i18n.t w/ tpl helper in serializers/output (#13401) * Replaced i18n.t w/ tpl helper in users refs: #13380 The i18n package is deprecated. It is being replaced with the tpl package. * Replaced i18n.t w/ tpl helper in authentication refs: #13380 The i18n package is deprecated. It is being replaced with the tpl package. Co-authored-by: Kenneth Fitzgerald --- .../utils/serializers/output/authentication.js | 14 ++++++++++---- .../api/canary/utils/serializers/output/users.js | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/server/api/canary/utils/serializers/output/authentication.js b/core/server/api/canary/utils/serializers/output/authentication.js index cf8d30241f..450bacaac3 100644 --- a/core/server/api/canary/utils/serializers/output/authentication.js +++ b/core/server/api/canary/utils/serializers/output/authentication.js @@ -1,7 +1,13 @@ -const i18n = require('../../../../../../shared/i18n'); +const tpl = require('@tryghost/tpl'); const mapper = require('./utils/mapper'); const debug = require('@tryghost/debug')('api:canary:utils:serializers:output:authentication'); +const messages = { + checkEmailForInstructions: 'Check your email for further instructions.', + passwordChanged: 'Password changed successfully.', + invitationAccepted: 'Invitation accepted.' +}; + module.exports = { setup(user, apiConfig, frame) { frame.response = { @@ -28,7 +34,7 @@ module.exports = { generateResetToken(data, apiConfig, frame) { frame.response = { passwordreset: [{ - message: i18n.t('common.api.authentication.mail.checkEmailForInstructions') + message: tpl(messages.checkEmailForInstructions) }] }; }, @@ -36,7 +42,7 @@ module.exports = { resetPassword(data, apiConfig, frame) { frame.response = { passwordreset: [{ - message: i18n.t('common.api.authentication.mail.passwordChanged') + message: tpl(messages.passwordChanged) }] }; }, @@ -46,7 +52,7 @@ module.exports = { frame.response = { invitation: [ - {message: i18n.t('common.api.authentication.mail.invitationAccepted')} + {message: tpl(messages.invitationAccepted)} ] }; }, diff --git a/core/server/api/canary/utils/serializers/output/users.js b/core/server/api/canary/utils/serializers/output/users.js index 2eec370e23..92be65fd56 100644 --- a/core/server/api/canary/utils/serializers/output/users.js +++ b/core/server/api/canary/utils/serializers/output/users.js @@ -1,7 +1,11 @@ const debug = require('@tryghost/debug')('api:canary:utils:serializers:output:users'); -const i18n = require('../../../../../../shared/i18n'); +const tpl = require('@tryghost/tpl'); const mapper = require('./utils/mapper'); +const messages = { + pwdChangedSuccessfully: 'Password changed successfully.' +}; + module.exports = { browse(models, apiConfig, frame) { debug('browse'); @@ -39,7 +43,7 @@ module.exports = { debug('changePassword'); frame.response = { - password: [{message: i18n.t('notices.api.users.pwdChangedSuccessfully')}] + password: [{message: tpl(messages.pwdChangedSuccessfully)}] }; },