mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00: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 models = require('../../models');
|
||||
const routeSettings = require('../../services/route-settings');
|
||||
const i18n = require('../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const {NoPermissionError, NotFoundError} = require('@tryghost/errors');
|
||||
const settingsService = require('../../services/settings');
|
||||
const settingsCache = require('../../../shared/settings-cache');
|
||||
|
||||
const messages = {
|
||||
problemFindingSetting: 'Problem finding setting: {key}',
|
||||
accessCoreSettingFromExtReq: 'Attempted to access core setting from external request'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
docName: 'settings',
|
||||
|
||||
|
@ -71,16 +76,14 @@ module.exports = {
|
|||
|
||||
if (!setting) {
|
||||
return Promise.reject(new NotFoundError({
|
||||
message: i18n.t('errors.api.settings.problemFindingSetting', {
|
||||
key: frame.options.key
|
||||
})
|
||||
message: tpl(messages.problemFindingSetting, {key: frame.options.key})
|
||||
}));
|
||||
}
|
||||
|
||||
// @TODO: handle in settings model permissible fn
|
||||
if (setting.group === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
||||
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) => {
|
||||
if (setting.group === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
||||
errors.push(new NoPermissionError({
|
||||
message: i18n.t('errors.api.settings.accessCoreSettingFromExtReq')
|
||||
message: tpl(messages.accessCoreSettingFromExtReq)
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -139,14 +142,12 @@ module.exports = {
|
|||
|
||||
if (!settingFromCache) {
|
||||
errors.push(new NotFoundError({
|
||||
message: i18n.t('errors.api.settings.problemFindingSetting', {
|
||||
key: setting.key
|
||||
})
|
||||
message: tpl(messages.problemFindingSetting, {key: setting.key})
|
||||
}));
|
||||
} else if (settingFromCache.core === 'core' && !(frame.options.context && frame.options.context.internal)) {
|
||||
// @TODO: handle in settings model permissible fn
|
||||
errors.push(new NoPermissionError({
|
||||
message: i18n.t('errors.api.settings.accessCoreSettingFromExtReq')
|
||||
message: tpl(messages.accessCoreSettingFromExtReq)
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue