Skip to content

Commit ca149f2

Browse files
committed
Replaced i18n.t w/ tpl helper in LocalFileStorage
refs: #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
1 parent 94050d3 commit ca149f2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

core/server/adapters/storage/LocalFileStorage.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ const path = require('path');
77
const Promise = require('bluebird');
88
const moment = require('moment');
99
const config = require('../../../shared/config');
10-
const i18n = require('../../../shared/i18n');
10+
const tpl = require('@tryghost/tpl');
1111
const logging = require('@tryghost/logging');
1212
const errors = require('@tryghost/errors');
1313
const constants = require('@tryghost/constants');
1414
const urlUtils = require('../../../shared/url-utils');
1515
const StorageBase = require('ghost-storage-base');
1616

17+
const messages = {
18+
imageNotFound: 'Image not found',
19+
imageNotFoundWithRef: 'Image not found: {img}',
20+
cannotReadImage: 'Could not read image: {img}'
21+
};
22+
1723
class LocalFileStore extends StorageBase {
1824
constructor() {
1925
super();
@@ -119,7 +125,7 @@ class LocalFileStore extends StorageBase {
119125
if (err) {
120126
if (err.statusCode === 404) {
121127
return next(new errors.NotFoundError({
122-
message: i18n.t('errors.errors.imageNotFound'),
128+
message: tpl(messages.imageNotFound),
123129
code: 'STATIC_FILE_NOT_FOUND',
124130
property: err.path
125131
}));
@@ -169,7 +175,7 @@ class LocalFileStore extends StorageBase {
169175
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
170176
return reject(new errors.NotFoundError({
171177
err: err,
172-
message: i18n.t('errors.errors.imageNotFoundWithRef', {img: options.path})
178+
message: tpl(messages.imageNotFoundWithRef, {img: options.path})
173179
}));
174180
}
175181

@@ -183,7 +189,7 @@ class LocalFileStore extends StorageBase {
183189

184190
return reject(new errors.GhostError({
185191
err: err,
186-
message: i18n.t('errors.errors.cannotReadImage', {img: options.path})
192+
message: tpl(messages.cannotReadImage, {img: options.path})
187193
}));
188194
}
189195

0 commit comments

Comments
 (0)