mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Replaced i18n.t w/ tpl helper in email and integrations (#13424)
refs: #13380 The i18n package is deprecated. It is being replaced with the tpl package. * Replaced i18n.t w/ tpl helper in email * Replaced i18n.t w/ tpl helper in integrations
This commit is contained in:
parent
31b998e1e1
commit
acf4a4b227
2 changed files with 16 additions and 11 deletions
|
@ -1,8 +1,13 @@
|
|||
const models = require('../../models');
|
||||
const i18n = require('../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const errors = require('@tryghost/errors');
|
||||
const megaService = require('../../services/mega');
|
||||
|
||||
const messages = {
|
||||
emailNotFound: 'Email not found.',
|
||||
retryNotAllowed: 'Only failed emails can be retried'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
docName: 'emails',
|
||||
|
||||
|
@ -38,7 +43,7 @@ module.exports = {
|
|||
.then((model) => {
|
||||
if (!model) {
|
||||
throw new errors.NotFoundError({
|
||||
message: i18n.t('errors.models.email.emailNotFound')
|
||||
message: tpl(messages.emailNotFound)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -57,13 +62,13 @@ module.exports = {
|
|||
.then(async (model) => {
|
||||
if (!model) {
|
||||
throw new errors.NotFoundError({
|
||||
message: i18n.t('errors.models.email.emailNotFound')
|
||||
message: tpl(messages.emailNotFound)
|
||||
});
|
||||
}
|
||||
|
||||
if (model.get('status') !== 'failed') {
|
||||
throw new errors.IncorrectUsageError({
|
||||
message: i18n.t('errors.models.email.retryNotAllowed')
|
||||
message: tpl(messages.retryNotAllowed)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
const i18n = require('../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const errors = require('@tryghost/errors');
|
||||
const models = require('../../models');
|
||||
const getIntegrationsServiceInstance = require('../../services/integrations/integrations-service');
|
||||
|
||||
const messages = {
|
||||
resourceNotFound: '{resource} not found.'
|
||||
};
|
||||
|
||||
const integrationsService = getIntegrationsServiceInstance({
|
||||
IntegrationModel: models.Integration,
|
||||
ApiKeyModel: models.ApiKey
|
||||
|
@ -51,9 +55,7 @@ module.exports = {
|
|||
return models.Integration.findOne(data, Object.assign(options, {require: true}))
|
||||
.catch(models.Integration.NotFoundError, () => {
|
||||
throw new errors.NotFoundError({
|
||||
message: i18n.t('errors.api.resource.resourceNotFound', {
|
||||
resource: 'Integration'
|
||||
})
|
||||
message: tpl(messages.resourceNotFound, {resource: 'Integration'})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -136,9 +138,7 @@ module.exports = {
|
|||
return models.Integration.destroy(Object.assign(options, {require: true}))
|
||||
.catch(models.Integration.NotFoundError, () => {
|
||||
return Promise.reject(new errors.NotFoundError({
|
||||
message: i18n.t('errors.api.resource.resourceNotFound', {
|
||||
resource: 'Integration'
|
||||
})
|
||||
message: tpl(messages.resourceNotFound, {resource: 'Integration'})
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue