mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
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:
parent
9822dbc1a2
commit
fe7f78f527
@ -1,11 +1,15 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const debug = require('@tryghost/debug')('frontend:services:settings:settings-loader');
|
const debug = require('@tryghost/debug')('frontend:services:settings:settings-loader');
|
||||||
const {i18n} = require('../proxy');
|
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const config = require('../../../shared/config');
|
const config = require('../../../shared/config');
|
||||||
const yamlParser = require('./yaml-parser');
|
const yamlParser = require('./yaml-parser');
|
||||||
const validate = require('./validate');
|
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) => {
|
const getSettingFilePath = (setting) => {
|
||||||
// we only support the `yaml` file extension. `yml` will be ignored.
|
// we only support the `yaml` file extension. `yml` will be ignored.
|
||||||
@ -26,7 +30,7 @@ const getSettingFilePath = (setting) => {
|
|||||||
* to prevent blocking the eventloop
|
* to prevent blocking the eventloop
|
||||||
*
|
*
|
||||||
* @param {String} setting the requested settings as defined in setting knownSettings
|
* @param {String} setting the requested settings as defined in setting knownSettings
|
||||||
* @returns {Object} settingsFile
|
* @returns {Promise<Object>} settingsFile
|
||||||
*/
|
*/
|
||||||
const loadSettings = async (setting) => {
|
const loadSettings = async (setting) => {
|
||||||
const {fileName, contentPath, filePath} = getSettingFilePath(setting);
|
const {fileName, contentPath, filePath} = getSettingFilePath(setting);
|
||||||
@ -43,7 +47,7 @@ const loadSettings = async (setting) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw new errors.GhostError({
|
throw new errors.GhostError({
|
||||||
message: i18n.t('errors.services.settings.loader', {
|
message: tpl(messages.settingsLoaderError, {
|
||||||
setting: setting,
|
setting: setting,
|
||||||
path: contentPath
|
path: contentPath
|
||||||
}),
|
}),
|
||||||
@ -76,7 +80,7 @@ module.exports.loadSettingsSync = function loadSettingsSync(setting) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw new errors.GhostError({
|
throw new errors.GhostError({
|
||||||
message: i18n.t('errors.services.settings.loader', {
|
message: tpl(messages.settingsLoaderError, {
|
||||||
setting: setting,
|
setting: setting,
|
||||||
path: contentPath
|
path: contentPath
|
||||||
}),
|
}),
|
||||||
|
@ -544,8 +544,7 @@
|
|||||||
"error": "Could not parse {file}: {context}.",
|
"error": "Could not parse {file}: {context}.",
|
||||||
"help": "Check your {file} file for typos and fix the named issues.",
|
"help": "Check your {file} file for typos and fix the named issues.",
|
||||||
"validate": "The following definition \"{at}\" is invalid: {reason}"
|
"validate": "The following definition \"{at}\" is invalid: {reason}"
|
||||||
},
|
}
|
||||||
"loader": "Error trying to load YAML setting for {setting} from '{path}'."
|
|
||||||
},
|
},
|
||||||
"mega": {
|
"mega": {
|
||||||
"requestFailed": {
|
"requestFailed": {
|
||||||
|
Loading…
Reference in New Issue
Block a user