diff --git a/core/frontend/services/redirects/settings.js b/core/frontend/services/redirects/settings.js index 245df8c00a..2006d24d6e 100644 --- a/core/frontend/services/redirects/settings.js +++ b/core/frontend/services/redirects/settings.js @@ -4,11 +4,16 @@ const moment = require('moment-timezone'); const yaml = require('js-yaml'); const Promise = require('bluebird'); const validation = require('./validation'); +const tpl = require('@tryghost/tpl'); const config = require('../../../shared/config'); -const i18n = require('../../../shared/i18n'); const errors = require('@tryghost/errors'); +const messages = { + jsonParse: 'Could not parse JSON: {context}.', + yamlParse: 'YAML input cannot be a plain string. Check the format of your YAML file.' +}; + /** * Redirect configuration object * @typedef {Object} RedirectConfig @@ -49,7 +54,7 @@ const parseRedirectsFile = (content, ext) => { redirects = JSON.parse(content); } catch (err) { throw new errors.BadRequestError({ - message: i18n.t('errors.general.jsonParse', {context: err.message}) + message: tpl(messages.jsonParse, {context: err.message}) }); } @@ -66,7 +71,7 @@ const parseRedirectsFile = (content, ext) => { // Here we check if the user made this mistake. if (typeof configYaml === 'string') { throw new errors.BadRequestError({ - message: i18n.t('errors.api.redirects.yamlParse'), + message: messages.yamlParse, help: 'https://ghost.org/docs/themes/routing/#redirects' }); } diff --git a/core/shared/i18n/translations/en.json b/core/shared/i18n/translations/en.json index 627cffc0e4..41f71eb461 100644 --- a/core/shared/i18n/translations/en.json +++ b/core/shared/i18n/translations/en.json @@ -106,8 +106,7 @@ }, "images": { "invalidDimensions": "Could not fetch image dimensions." - }, - "redirectsWrongFormat": "Incorrect redirects file format." + } }, "config": { "couldNotLocateConfigFile": { @@ -157,8 +156,7 @@ "maintenance": "Site is currently undergoing maintenance, please wait a moment then retry.", "maintenanceUrlService": "Site is starting up, please wait a moment then retry.", "requiredOnFuture": "This will be required in future. Please see {link}", - "internalError": "Something went wrong.", - "jsonParse": "Could not parse JSON: {context}." + "internalError": "Something went wrong." }, "mail": { "incompleteMessageData": {