mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Replaced i18n.t w/ tpl helper in LocalFileStorage
refs: https://github.com/TryGhost/Ghost/issues/13380 - this is a refactor we are looking to do everywhere - this commit is a reference for how to do the refactor: in small minimal pieces
This commit is contained in:
parent
94050d37cd
commit
ca149f2c0e
1 changed files with 10 additions and 4 deletions
|
@ -7,13 +7,19 @@ const path = require('path');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const config = require('../../../shared/config');
|
const config = require('../../../shared/config');
|
||||||
const i18n = require('../../../shared/i18n');
|
const tpl = require('@tryghost/tpl');
|
||||||
const logging = require('@tryghost/logging');
|
const logging = require('@tryghost/logging');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const constants = require('@tryghost/constants');
|
const constants = require('@tryghost/constants');
|
||||||
const urlUtils = require('../../../shared/url-utils');
|
const urlUtils = require('../../../shared/url-utils');
|
||||||
const StorageBase = require('ghost-storage-base');
|
const StorageBase = require('ghost-storage-base');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
imageNotFound: 'Image not found',
|
||||||
|
imageNotFoundWithRef: 'Image not found: {img}',
|
||||||
|
cannotReadImage: 'Could not read image: {img}'
|
||||||
|
};
|
||||||
|
|
||||||
class LocalFileStore extends StorageBase {
|
class LocalFileStore extends StorageBase {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -119,7 +125,7 @@ class LocalFileStore extends StorageBase {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.statusCode === 404) {
|
if (err.statusCode === 404) {
|
||||||
return next(new errors.NotFoundError({
|
return next(new errors.NotFoundError({
|
||||||
message: i18n.t('errors.errors.imageNotFound'),
|
message: tpl(messages.imageNotFound),
|
||||||
code: 'STATIC_FILE_NOT_FOUND',
|
code: 'STATIC_FILE_NOT_FOUND',
|
||||||
property: err.path
|
property: err.path
|
||||||
}));
|
}));
|
||||||
|
@ -169,7 +175,7 @@ class LocalFileStore extends StorageBase {
|
||||||
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
|
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
|
||||||
return reject(new errors.NotFoundError({
|
return reject(new errors.NotFoundError({
|
||||||
err: err,
|
err: err,
|
||||||
message: i18n.t('errors.errors.imageNotFoundWithRef', {img: options.path})
|
message: tpl(messages.imageNotFoundWithRef, {img: options.path})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +189,7 @@ class LocalFileStore extends StorageBase {
|
||||||
|
|
||||||
return reject(new errors.GhostError({
|
return reject(new errors.GhostError({
|
||||||
err: err,
|
err: err,
|
||||||
message: i18n.t('errors.errors.cannotReadImage', {img: options.path})
|
message: tpl(messages.cannotReadImage, {img: options.path})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue