mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Removed use of i18n in Bookshelf plugins
no issue - i18n is eventually going away in Ghost so we want to remove uses of it - Bookshelf plugins are also getting extraced out of Ghost so we need to remove all local requires - i18n is being replaced by inline templating with strings stored in the `messages` object - this commit switches out the use of i18n in the Bookshelf plugins and replaces the templating function with our `@tryghost/tpl` package
This commit is contained in:
parent
1ec7c70c6f
commit
d783a8d2d4
@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user