mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05: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
2 changed files with 17 additions and 7 deletions
|
@ -1,6 +1,10 @@
|
||||||
const debug = require('ghost-ignition').debug('models:plugins:filter');
|
const debug = require('ghost-ignition').debug('models:plugins:filter');
|
||||||
const i18n = require('../../../shared/i18n');
|
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
|
const tpl = require('@tryghost/tpl');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
errorParsing: 'Error parsing filter'
|
||||||
|
};
|
||||||
|
|
||||||
const RELATIONS = {
|
const RELATIONS = {
|
||||||
tags: {
|
tags: {
|
||||||
|
@ -133,8 +137,8 @@ const filter = function filter(Bookshelf) {
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new errors.BadRequestError({
|
throw new errors.BadRequestError({
|
||||||
message: i18n.t('errors.models.plugins.filter.errorParsing'),
|
message: tpl(messages.errorParsing),
|
||||||
err: err
|
err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,14 @@
|
||||||
// Extends Bookshelf.Model with a `fetchPage` method. Handles everything to do with paginated requests.
|
// Extends Bookshelf.Model with a `fetchPage` method. Handles everything to do with paginated requests.
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const i18n = require('../../../shared/i18n');
|
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
|
const tpl = require('@tryghost/tpl');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
pageNotFound: 'Page not found'
|
||||||
|
couldNotUnderstandRequest: 'Could not understand request.'
|
||||||
|
};
|
||||||
|
|
||||||
let defaults;
|
let defaults;
|
||||||
let paginationUtils;
|
let paginationUtils;
|
||||||
|
|
||||||
|
@ -242,7 +248,7 @@ const pagination = function pagination(bookshelf) {
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
// e.g. offset/limit reached max allowed integer value
|
// e.g. offset/limit reached max allowed integer value
|
||||||
if (err.errno === 20 || err.errno === 1064) {
|
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;
|
throw err;
|
||||||
|
@ -251,8 +257,8 @@ const pagination = function pagination(bookshelf) {
|
||||||
// CASE: SQL syntax is incorrect
|
// CASE: SQL syntax is incorrect
|
||||||
if (err.errno === 1054 || err.errno === 1) {
|
if (err.errno === 1054 || err.errno === 1) {
|
||||||
throw new errors.BadRequestError({
|
throw new errors.BadRequestError({
|
||||||
message: i18n.t('errors.models.general.sql'),
|
message: tpl(messages.couldNotUnderstandRequest),
|
||||||
err: err
|
err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue