0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Removed i18n from backend theme code

- slowly slowly removing the @deprecated i18n code from everywhere in favour of tpl
This commit is contained in:
Hannah Wolfe 2021-07-06 15:38:28 +01:00
parent dda884ee4f
commit ee5962bd5d
No known key found for this signature in database
GPG key ID: 9F8C7532D0A6BA55
2 changed files with 20 additions and 8 deletions

View file

@ -9,12 +9,20 @@ const themeLoader = require('./loader');
const toJSON = require('./to-json');
const settingsCache = require('../../../shared/settings-cache');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const logging = require('@tryghost/logging');
const errors = require('@tryghost/errors');
const ObjectID = require('bson-objectid');
const messages = {
themeDoesNotExist: 'Theme does not exist.',
invalidThemeName: 'Please select a valid theme.',
overrideCasper: 'Please rename your zip, it\'s not allowed to override the default casper theme.',
destroyCasper: 'Deleting the default casper theme is not allowed.',
destroyActive: 'Deleting the active theme is not allowed.'
};
let themeStorage;
const getStorage = () => {
@ -29,7 +37,7 @@ module.exports = {
if (!theme) {
return Promise.reject(new errors.BadRequestError({
message: i18n.t('errors.api.themes.invalidThemeName')
message: tpl(messages.invalidThemeName)
}));
}
@ -44,7 +52,7 @@ module.exports = {
// check if zip name is casper.zip
if (zip.name === 'casper.zip') {
throw new errors.ValidationError({
message: i18n.t('errors.api.themes.overrideCasper')
message: tpl(messages.overrideCasper)
});
}
@ -124,13 +132,13 @@ module.exports = {
destroy: function (themeName) {
if (themeName === 'casper') {
throw new errors.ValidationError({
message: i18n.t('errors.api.themes.destroyCasper')
message: tpl(messages.destroyCasper)
});
}
if (themeName === settingsCache.get('active_theme')) {
throw new errors.ValidationError({
message: i18n.t('errors.api.themes.destroyActive')
message: tpl(messages.destroyActive)
});
}
@ -138,7 +146,7 @@ module.exports = {
if (!theme) {
throw new errors.NotFoundError({
message: i18n.t('errors.api.themes.themeDoesNotExist')
message: tpl(messages.themeDoesNotExist)
});
}

View file

@ -3,9 +3,13 @@ const _ = require('lodash');
const Promise = require('bluebird');
const fs = require('fs-extra');
const config = require('../../../shared/config');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const messages = {
invalidTheme: 'Theme is not compatible or contains errors.'
};
const canActivate = function canActivate(checkedTheme) {
// CASE: production and no fatal errors
// CASE: development returns fatal and none fatal errors, theme is only invalid if fatal errors
@ -61,7 +65,7 @@ const checkSafe = function checkSafe(theme, isZip) {
}
return Promise.reject(new errors.ThemeValidationError({
message: i18n.t('errors.api.themes.invalidTheme'),
message: tpl(messages.invalidTheme),
errorDetails: Object.assign(
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
errors: checkedTheme.results.error