Replaced i18n.t w/ tpl helper in invites.js (#13433)

refs: #13380

* The i18n package is deprecated. It is being replaced with the tpl package.
* Replaced i18n.t w/ tpl helper in invites.js
* Replaced i18n.t w/ tpl helper in labels.js
This commit is contained in:
Ania Kowalska 2021-10-06 10:49:20 +02:00 committed by GitHub
parent 6ff63dc220
commit dff788c64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -1,5 +1,5 @@
const Promise = require('bluebird');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const invites = require('../../services/invites');
const models = require('../../models');
@ -7,6 +7,10 @@ const api = require('./index');
const ALLOWED_INCLUDES = [];
const UNSAFE_ATTRS = ['role_id'];
const messages = {
inviteNotFound: 'Invite not found.'
};
module.exports = {
docName: 'invites',
@ -50,7 +54,7 @@ module.exports = {
.then((model) => {
if (!model) {
return Promise.reject(new errors.NotFoundError({
message: i18n.t('errors.api.invites.inviteNotFound')
message: tpl(messages.inviteNotFound)
}));
}
@ -78,7 +82,7 @@ module.exports = {
.then(() => null)
.catch(models.Invite.NotFoundError, () => {
return Promise.reject(new errors.NotFoundError({
message: i18n.t('errors.api.invites.inviteNotFound')
message: tpl(messages.inviteNotFound)
}));
});
}

View File

@ -1,8 +1,13 @@
const Promise = require('bluebird');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const models = require('../../models');
const messages = {
labelNotFound: 'Label not found.',
labelAlreadyExists: 'Label already exists'
};
const ALLOWED_INCLUDES = ['count.members'];
module.exports = {
@ -53,7 +58,7 @@ module.exports = {
.then((model) => {
if (!model) {
return Promise.reject(new errors.NotFoundError({
message: i18n.t('errors.api.labels.labelNotFound')
message: tpl(messages.labelNotFound)
}));
}
@ -80,7 +85,7 @@ module.exports = {
return models.Label.add(frame.data.labels[0], frame.options)
.catch((error) => {
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
throw new errors.ValidationError({message: i18n.t('errors.api.labels.labelAlreadyExists')});
throw new errors.ValidationError({message: tpl(messages.labelAlreadyExists)});
}
throw error;
@ -110,7 +115,7 @@ module.exports = {
.then((model) => {
if (!model) {
return Promise.reject(new errors.NotFoundError({
message: i18n.t('errors.api.labels.labelNotFound')
message: tpl(messages.labelNotFound)
}));
}
@ -149,7 +154,7 @@ module.exports = {
.then(() => null)
.catch(models.Label.NotFoundError, () => {
return Promise.reject(new errors.NotFoundError({
message: i18n.t('errors.api.labels.labelNotFound')
message: tpl(messages.labelNotFound)
}));
});
}