Removed i18n dependency from settings loader 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:
Naz 2021-09-23 16:46:10 +02:00 committed by naz
parent 9822dbc1a2
commit fe7f78f527
2 changed files with 9 additions and 6 deletions

View File

@ -1,11 +1,15 @@
const fs = require('fs-extra');
const path = require('path');
const debug = require('@tryghost/debug')('frontend:services:settings:settings-loader');
const {i18n} = require('../proxy');
const errors = require('@tryghost/errors');
const config = require('../../../shared/config');
const yamlParser = require('./yaml-parser');
const validate = require('./validate');
const tpl = require('@tryghost/tpl');
const messages = {
settingsLoaderError: `Error trying to load YAML setting for {setting} from '{path}'.`
};
const getSettingFilePath = (setting) => {
// we only support the `yaml` file extension. `yml` will be ignored.
@ -26,7 +30,7 @@ const getSettingFilePath = (setting) => {
* to prevent blocking the eventloop
*
* @param {String} setting the requested settings as defined in setting knownSettings
* @returns {Object} settingsFile
* @returns {Promise<Object>} settingsFile
*/
const loadSettings = async (setting) => {
const {fileName, contentPath, filePath} = getSettingFilePath(setting);
@ -43,7 +47,7 @@ const loadSettings = async (setting) => {
}
throw new errors.GhostError({
message: i18n.t('errors.services.settings.loader', {
message: tpl(messages.settingsLoaderError, {
setting: setting,
path: contentPath
}),
@ -76,7 +80,7 @@ module.exports.loadSettingsSync = function loadSettingsSync(setting) {
}
throw new errors.GhostError({
message: i18n.t('errors.services.settings.loader', {
message: tpl(messages.settingsLoaderError, {
setting: setting,
path: contentPath
}),

View File

@ -544,8 +544,7 @@
"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}"
},
"loader": "Error trying to load YAML setting for {setting} from '{path}'."
}
},
"mega": {
"requestFailed": {