mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Removed i18n dependency from yaml parser module
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings - i18n is an old pattern we are getting rid of. By removing it here we get rid of an extra dependancy on frontend's "proxy" module
This commit is contained in:
parent
fe7f78f527
commit
c3f9233165
2 changed files with 10 additions and 5 deletions
|
@ -1,8 +1,15 @@
|
|||
const yaml = require('js-yaml');
|
||||
const debug = require('@tryghost/debug')('frontend:services:settings:yaml-parser');
|
||||
const {i18n} = require('../proxy');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const errors = require('@tryghost/errors');
|
||||
|
||||
const messages = {
|
||||
yamlParsing: {
|
||||
error: 'Could not parse {file}: {context}.',
|
||||
help: 'Check your {file} file for typos and fix the named issues.'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a YAML file, parses it and returns a JSON Object
|
||||
* @param {YAML} file the YAML file utf8 encoded
|
||||
|
@ -21,11 +28,11 @@ module.exports = function parseYaml(file, fileName) {
|
|||
// `reason` property as well as in the message.
|
||||
// As the file uploaded is invalid, the person uploading must fix this - it's a 4xx error
|
||||
throw new errors.IncorrectUsageError({
|
||||
message: i18n.t('errors.services.settings.yaml.error', {file: fileName, context: error.reason}),
|
||||
message: tpl(messages.yamlParsing.error, {file: fileName, context: error.reason}),
|
||||
code: 'YAML_PARSER_ERROR',
|
||||
context: error.message,
|
||||
err: error,
|
||||
help: i18n.t('errors.services.settings.yaml.help', {file: fileName})
|
||||
help: tpl(messages.yamlParsing.help, {file: fileName})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -541,8 +541,6 @@
|
|||
"services": {
|
||||
"settings": {
|
||||
"yaml": {
|
||||
"error": "Could not parse {file}: {context}.",
|
||||
"help": "Check your {file} file for typos and fix the named issues.",
|
||||
"validate": "The following definition \"{at}\" is invalid: {reason}"
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue