diff --git a/core/server/models/plugins/filter.js b/core/server/models/plugins/filter.js index e0e5a4e3b8..104ca9a079 100644 --- a/core/server/models/plugins/filter.js +++ b/core/server/models/plugins/filter.js @@ -1,6 +1,10 @@ const debug = require('ghost-ignition').debug('models:plugins:filter'); -const i18n = require('../../../shared/i18n'); const errors = require('@tryghost/errors'); +const tpl = require('@tryghost/tpl'); + +const messages = { + errorParsing: 'Error parsing filter' +}; const RELATIONS = { tags: { @@ -133,8 +137,8 @@ const filter = function filter(Bookshelf) { }); } catch (err) { throw new errors.BadRequestError({ - message: i18n.t('errors.models.plugins.filter.errorParsing'), - err: err + message: tpl(messages.errorParsing), + err }); } } diff --git a/core/server/models/plugins/pagination.js b/core/server/models/plugins/pagination.js index 74b3df34e7..ab3c4647b9 100644 --- a/core/server/models/plugins/pagination.js +++ b/core/server/models/plugins/pagination.js @@ -3,8 +3,14 @@ // Extends Bookshelf.Model with a `fetchPage` method. Handles everything to do with paginated requests. const _ = require('lodash'); -const i18n = require('../../../shared/i18n'); const errors = require('@tryghost/errors'); +const tpl = require('@tryghost/tpl'); + +const messages = { + pageNotFound: 'Page not found' + couldNotUnderstandRequest: 'Could not understand request.' +}; + let defaults; let paginationUtils; @@ -242,7 +248,7 @@ const pagination = function pagination(bookshelf) { .catch(function (err) { // e.g. offset/limit reached max allowed integer value if (err.errno === 20 || err.errno === 1064) { - throw new errors.NotFoundError({message: i18n.t('errors.errors.pageNotFound')}); + throw new errors.NotFoundError({message: tpl(messages.pageNotFound)}); } throw err; @@ -251,8 +257,8 @@ const pagination = function pagination(bookshelf) { // CASE: SQL syntax is incorrect if (err.errno === 1054 || err.errno === 1) { throw new errors.BadRequestError({ - message: i18n.t('errors.models.general.sql'), - err: err + message: tpl(messages.couldNotUnderstandRequest), + err }); }