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:
parent
368b5e41db
commit
cadd63bc9c
4 changed files with 32 additions and 10 deletions
|
@ -3,9 +3,13 @@ const Promise = require('bluebird');
|
||||||
const db = require('../../data/db');
|
const db = require('../../data/db');
|
||||||
const commands = require('../schema').commands;
|
const commands = require('../schema').commands;
|
||||||
const ghostVersion = require('@tryghost/version');
|
const ghostVersion = require('@tryghost/version');
|
||||||
const i18n = require('../../../shared/i18n');
|
const tpl = require('@tryghost/tpl');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
errorExportingData: 'Error exporting data'
|
||||||
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
TABLES_ALLOWLIST,
|
TABLES_ALLOWLIST,
|
||||||
SETTING_KEYS_BLOCKLIST
|
SETTING_KEYS_BLOCKLIST
|
||||||
|
@ -58,7 +62,7 @@ const doExport = async function doExport(options) {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new errors.DataExportError({
|
throw new errors.DataExportError({
|
||||||
err: err,
|
err: err,
|
||||||
context: i18n.t('errors.data.export.errorExportingData')
|
context: tpl(messages.errorExportingData)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const i18n = require('../../../../shared/i18n');
|
const tpl = require('@tryghost/tpl');
|
||||||
const errors = require('@tryghost/errors');
|
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;
|
let JSONHandler;
|
||||||
|
|
||||||
JSONHandler = {
|
JSONHandler = {
|
||||||
|
@ -25,7 +31,7 @@ JSONHandler = {
|
||||||
if (_.keys(importData).length === 1) {
|
if (_.keys(importData).length === 1) {
|
||||||
if (!importData.db || !Array.isArray(importData.db)) {
|
if (!importData.db || !Array.isArray(importData.db)) {
|
||||||
throw new errors.GhostError({
|
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({
|
return Promise.reject(new errors.BadRequestError({
|
||||||
err: err,
|
err: err,
|
||||||
message: err.message,
|
message: err.message,
|
||||||
help: i18n.t('errors.data.importer.handlers.json.checkImportJsonIsValid')
|
help: tpl(messages.checkImportJsonIsValid)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,6 +16,18 @@ const MarkdownHandler = require('./handlers/markdown');
|
||||||
const ImageImporter = require('./importers/image');
|
const ImageImporter = require('./importers/image');
|
||||||
const DataImporter = require('./importers/data');
|
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
|
// Glob levels
|
||||||
const ROOT_ONLY = 0;
|
const ROOT_ONLY = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const i18n = require('../../../shared/i18n');
|
|
||||||
const logging = require('@tryghost/logging');
|
const logging = require('@tryghost/logging');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const tpl = require('@tryghost/tpl');
|
const tpl = require('@tryghost/tpl');
|
||||||
|
@ -10,7 +9,8 @@ const clients = require('./clients');
|
||||||
|
|
||||||
const messages = {
|
const messages = {
|
||||||
hasPrimaryKeySQLiteError: 'Must use hasPrimaryKeySQLite on an SQLite3 database',
|
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]) {
|
function addTableColumn(tableName, table, columnName, columnSpec = schema[tableName][columnName]) {
|
||||||
|
@ -343,7 +343,7 @@ function getTables(transaction) {
|
||||||
return clients[client].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) {
|
function getIndexes(table, transaction) {
|
||||||
|
@ -353,7 +353,7 @@ function getIndexes(table, transaction) {
|
||||||
return clients[client].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) {
|
function getColumns(table, transaction) {
|
||||||
|
@ -363,7 +363,7 @@ function getColumns(table, transaction) {
|
||||||
return clients[client].getColumns(table);
|
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) {
|
function checkTables(transaction) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue