0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Replace i18n with tpl in some files under core/server/api/v2 (#13445)

refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Replace the deprecated dependency `i18n` with `tpl` in the following files under
`core/server/api/v2/`:

- authors-public.js
- pages-public.js
- session.js
This commit is contained in:
Bruno Silva 2021-10-05 06:36:12 -03:00 committed by GitHub
parent b69c39ba13
commit bf4c5c861d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 deletions

View file

@ -1,9 +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 ALLOWED_INCLUDES = ['count.posts'];
const messages = {
authorsNotFound: 'Author not found.'
};
module.exports = {
docName: 'authors',
@ -54,7 +58,7 @@ module.exports = {
.then((model) => {
if (!model) {
return Promise.reject(new errors.NotFoundError({
message: i18n.t('errors.api.authors.notFound')
message: tpl(messages.authorsNotFound)
}));
}

View file

@ -1,8 +1,12 @@
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const models = require('../../models');
const ALLOWED_INCLUDES = ['tags', 'authors'];
const messages = {
pageNotFound: 'Page not found'
};
module.exports = {
docName: 'pages',
@ -63,7 +67,7 @@ module.exports = {
.then((model) => {
if (!model) {
throw new errors.NotFoundError({
message: i18n.t('errors.api.pages.pageNotFound')
message: tpl(messages.pageNotFound)
});
}

View file

@ -1,10 +1,14 @@
const Promise = require('bluebird');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const models = require('../../models');
const auth = require('../../services/auth');
const api = require('./index');
const messages = {
authAccessDenied: 'Access denied.'
};
const session = {
read(frame) {
/*
@ -20,7 +24,7 @@ const session = {
if (!object || !object.username || !object.password) {
return Promise.reject(new errors.UnauthorizedError({
message: i18n.t('errors.middleware.auth.accessDenied')
message: tpl(messages.authAccessDenied)
}));
}
@ -40,7 +44,7 @@ const session = {
}).catch(async (err) => {
if (!errors.utils.isIgnitionError(err)) {
throw new errors.UnauthorizedError({
message: i18n.t('errors.middleware.auth.accessDenied'),
message: tpl(messages.authAccessDenied),
err
});
}