0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Refactored i18n out of redirects settings

refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- i18n is an old pattern we are getting rid of
This commit is contained in:
Naz 2021-09-27 19:00:08 +02:00
parent d316d9fdec
commit fb1d929b9d
2 changed files with 10 additions and 7 deletions

View file

@ -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'
});
}

View file

@ -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": {