mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Replaced i18n.t w/ tpl in v2/settings.js (#13504)
refs: TryGhost#13380 - The i18n package is deprecated. It is being replaced with the tpl package.
This commit is contained in:
parent
5ec272a377
commit
ace3ff033c
1 changed files with 11 additions and 10 deletions
|
@ -2,11 +2,16 @@ const Promise = require('bluebird');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
const routeSettings = require('../../services/route-settings');
|
const routeSettings = require('../../services/route-settings');
|
||||||
const i18n = require('../../../shared/i18n');
|
const tpl = require('@tryghost/tpl');
|
||||||
const {NoPermissionError, NotFoundError} = require('@tryghost/errors');
|
const {NoPermissionError, NotFoundError} = require('@tryghost/errors');
|
||||||
const settingsService = require('../../services/settings');
|
const settingsService = require('../../services/settings');
|
||||||
const settingsCache = require('../../../shared/settings-cache');
|
const settingsCache = require('../../../shared/settings-cache');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
problemFindingSetting: 'Problem finding setting: {key}',
|
||||||
|
accessCoreSettingFromExtReq: 'Attempted to access core setting from external request'
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
docName: 'settings',
|
docName: 'settings',
|
||||||
|
|
||||||
|
@ -71,16 +76,14 @@ module.exports = {
|
||||||
|
|
||||||
if (!setting) {
|
if (!setting) {
|
||||||
return Promise.reject(new NotFoundError({
|
return Promise.reject(new NotFoundError({
|
||||||
message: i18n.t('errors.api.settings.problemFindingSetting', {
|
message: tpl(messages.problemFindingSetting, {key: frame.options.key})
|
||||||
key: frame.options.key
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: handle in settings model permissible fn
|
// @TODO: handle in settings model permissible fn
|
||||||
if (setting.group === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
if (setting.group === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
||||||
return Promise.reject(new NoPermissionError({
|
return Promise.reject(new NoPermissionError({
|
||||||
message: i18n.t('errors.api.settings.accessCoreSettingFromExtReq')
|
message: tpl(messages.accessCoreSettingFromExtReq)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +109,7 @@ module.exports = {
|
||||||
frame.data.settings.map((setting) => {
|
frame.data.settings.map((setting) => {
|
||||||
if (setting.group === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
if (setting.group === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
||||||
errors.push(new NoPermissionError({
|
errors.push(new NoPermissionError({
|
||||||
message: i18n.t('errors.api.settings.accessCoreSettingFromExtReq')
|
message: tpl(messages.accessCoreSettingFromExtReq)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -139,14 +142,12 @@ module.exports = {
|
||||||
|
|
||||||
if (!settingFromCache) {
|
if (!settingFromCache) {
|
||||||
errors.push(new NotFoundError({
|
errors.push(new NotFoundError({
|
||||||
message: i18n.t('errors.api.settings.problemFindingSetting', {
|
message: tpl(messages.problemFindingSetting, {key: setting.key})
|
||||||
key: setting.key
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
} else if (settingFromCache.core === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
} else if (settingFromCache.core === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
||||||
// @TODO: handle in settings model permissible fn
|
// @TODO: handle in settings model permissible fn
|
||||||
errors.push(new NoPermissionError({
|
errors.push(new NoPermissionError({
|
||||||
message: i18n.t('errors.api.settings.accessCoreSettingFromExtReq')
|
message: tpl(messages.accessCoreSettingFromExtReq)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue