mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Replaced i18n.t w/ tpl in class OEmbed (#13492)
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
cadd63bc9c
commit
df0d92f060
3 changed files with 15 additions and 11 deletions
|
@ -1,8 +1,8 @@
|
|||
const config = require('../../../shared/config');
|
||||
const externalRequest = require('../../lib/request-external');
|
||||
const i18n = require('../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const OEmbed = require('../../services/oembed');
|
||||
const oembed = new OEmbed({config, externalRequest, i18n});
|
||||
const oembed = new OEmbed({config, externalRequest, tpl});
|
||||
|
||||
module.exports = {
|
||||
docName: 'oembed',
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const config = require('../../../shared/config');
|
||||
const externalRequest = require('../../lib/request-external');
|
||||
const i18n = require('../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const OEmbed = require('../../services/oembed');
|
||||
const oembed = new OEmbed({config, externalRequest, i18n});
|
||||
const oembed = new OEmbed({config, externalRequest, tpl});
|
||||
|
||||
module.exports = {
|
||||
docName: 'oembed',
|
||||
|
|
|
@ -5,6 +5,11 @@ const cheerio = require('cheerio');
|
|||
const _ = require('lodash');
|
||||
const {CookieJar} = require('tough-cookie');
|
||||
|
||||
const messages = {
|
||||
noUrlProvided: 'No url provided.',
|
||||
insufficientMetadata: 'URL contains insufficient metadata.'
|
||||
};
|
||||
|
||||
const findUrlWithProvider = (url) => {
|
||||
let provider;
|
||||
|
||||
|
@ -30,8 +35,7 @@ const findUrlWithProvider = (url) => {
|
|||
};
|
||||
|
||||
/**
|
||||
* @typedef {Object} Ii18n
|
||||
* @prop {(key: string) => string} t
|
||||
* @typedef {(string: string) => string} ITpl
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -47,19 +51,19 @@ class OEmbed {
|
|||
/**
|
||||
*
|
||||
* @param {Object} dependencies
|
||||
* @param {Ii18n} dependencies.i18n
|
||||
* @param {ITpl} dependencies.tpl
|
||||
* @param {IConfig} dependencies.config
|
||||
* @param {IExternalRequest} dependencies.externalRequest
|
||||
*/
|
||||
constructor({config, externalRequest, i18n}) {
|
||||
constructor({config, externalRequest, tpl}) {
|
||||
this.config = config;
|
||||
this.externalRequest = externalRequest;
|
||||
this.i18n = i18n;
|
||||
this.tpl = tpl;
|
||||
}
|
||||
|
||||
unknownProvider(url) {
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: this.i18n.t('errors.api.oembed.unknownProvider'),
|
||||
message: this.tpl(messages.unknownProvider),
|
||||
context: url
|
||||
}));
|
||||
}
|
||||
|
@ -129,7 +133,7 @@ class OEmbed {
|
|||
}
|
||||
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: this.i18n.t('errors.api.oembed.insufficientMetadata'),
|
||||
message: this.tpl(messages.insufficientMetadata),
|
||||
context: url
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue