0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Replaced i18n.t w/ tpl in core/server/data (#13491)

refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
This commit is contained in:
Aleksander Chromik 2021-10-08 16:31:17 +02:00 committed by GitHub
parent 368b5e41db
commit cadd63bc9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 10 deletions

View file

@ -3,9 +3,13 @@ const Promise = require('bluebird');
const db = require('../../data/db');
const commands = require('../schema').commands;
const ghostVersion = require('@tryghost/version');
const i18n = require('../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const messages = {
errorExportingData: 'Error exporting data'
};
const {
TABLES_ALLOWLIST,
SETTING_KEYS_BLOCKLIST
@ -58,7 +62,7 @@ const doExport = async function doExport(options) {
} catch (err) {
throw new errors.DataExportError({
err: err,
context: i18n.t('errors.data.export.errorExportingData')
context: tpl(messages.errorExportingData)
});
}
};

View file

@ -1,8 +1,14 @@
const _ = require('lodash');
const Promise = require('bluebird');
const fs = require('fs-extra');
const i18n = require('../../../../shared/i18n');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const messages = {
invalidJsonFormat: 'Invalid JSON format, expected `{ db: [exportedData] }`',
checkImportJsonIsValid: 'check that the import file is valid JSON.'
};
let JSONHandler;
JSONHandler = {
@ -25,7 +31,7 @@ JSONHandler = {
if (_.keys(importData).length === 1) {
if (!importData.db || !Array.isArray(importData.db)) {
throw new errors.GhostError({
message: i18n.t('errors.data.importer.handlers.json.invalidJsonFormat')
message: tpl(messages.invalidJsonFormat)
});
}
@ -37,7 +43,7 @@ JSONHandler = {
return Promise.reject(new errors.BadRequestError({
err: err,
message: err.message,
help: i18n.t('errors.data.importer.handlers.json.checkImportJsonIsValid')
help: tpl(messages.checkImportJsonIsValid)
}));
}
});

View file

@ -16,6 +16,18 @@ const MarkdownHandler = require('./handlers/markdown');
const ImageImporter = require('./importers/image');
const DataImporter = require('./importers/data');
const messages = {
couldNotCleanUpFile: {
error: 'Import could not clean up file ',
context: 'Your site will continue to work as expected'
},
unsupportedRoonExport: 'Your zip file looks like an old format Roon export, please re-export your Roon blog and try again.',
noContentToImport: 'Zip did not include any content to import.',
invalidZipStructure: 'Invalid zip file structure.',
invalidZipFileBaseDirectory: 'Invalid zip file: base directory read failed',
zipContainsMultipleDataFormats: 'Zip file contains multiple data formats. Please split up and import separately.'
};
// Glob levels
const ROOT_ONLY = 0;

View file

@ -1,6 +1,5 @@
const _ = require('lodash');
const Promise = require('bluebird');
const i18n = require('../../../shared/i18n');
const logging = require('@tryghost/logging');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
@ -10,7 +9,8 @@ const clients = require('./clients');
const messages = {
hasPrimaryKeySQLiteError: 'Must use hasPrimaryKeySQLite on an SQLite3 database',
hasForeignSQLite3: 'Must use hasForeignSQLite3 on an SQLite3 database'
hasForeignSQLite3: 'Must use hasForeignSQLite3 on an SQLite3 database',
noSupportForDatabase: 'No support for database client {client}'
};
function addTableColumn(tableName, table, columnName, columnSpec = schema[tableName][columnName]) {
@ -343,7 +343,7 @@ function getTables(transaction) {
return clients[client].getTables(transaction);
}
return Promise.reject(i18n.t('notices.data.utils.index.noSupportForDatabase', {client: client}));
return Promise.reject(tpl(messages.noSupportForDatabase, {client: client}));
}
function getIndexes(table, transaction) {
@ -353,7 +353,7 @@ function getIndexes(table, transaction) {
return clients[client].getIndexes(table, transaction);
}
return Promise.reject(i18n.t('notices.data.utils.index.noSupportForDatabase', {client: client}));
return Promise.reject(tpl(messages.noSupportForDatabase, {client: client}));
}
function getColumns(table, transaction) {
@ -363,7 +363,7 @@ function getColumns(table, transaction) {
return clients[client].getColumns(table);
}
return Promise.reject(i18n.t('notices.data.utils.index.noSupportForDatabase', {client: client}));
return Promise.reject(tpl(messages.noSupportForDatabase, {client: client}));
}
function checkTables(transaction) {