mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
9614d71e1f
refs: bf0823c9a2
- continuing the work of splitting up the theme service into logical components
- This one is a little more involved, as the i18n initialisation was unnecessarily spread over several locations.
- I moved it into being part of the ActiveTheme class and called in the constructor, meaning we don't need the services.theme.activated event anymore as the constructor is called in the same cases.
- Also moved the event listener for locales into the bridge, as I don't want that inside of theme-engine, and we don't want circular dependencies. We'll figure out a wayto refactor this soon too.
32 lines
903 B
JavaScript
32 lines
903 B
JavaScript
// @TODO: refactor constructor pattern so we don't have to require config here?
|
|
const config = require('./config');
|
|
const {events} = require('../server/lib/common');
|
|
const themeEngine = require('../frontend/services/theme-engine');
|
|
|
|
class Bridge {
|
|
constructor() {
|
|
/**
|
|
* When locale changes, we reload theme translations
|
|
* @deprecated: the term "lang" was deprecated in favour of "locale" publicly 4.0
|
|
*/
|
|
events.on('settings.lang.edited', () => {
|
|
this.getActiveTheme().initI18n();
|
|
});
|
|
}
|
|
|
|
getActiveTheme() {
|
|
return themeEngine.getActive();
|
|
}
|
|
|
|
getFrontendApiVersion() {
|
|
if (this.getActiveTheme()) {
|
|
return this.getActiveTheme().engine('ghost-api');
|
|
} else {
|
|
return config.get('api:versions:default');
|
|
}
|
|
}
|
|
}
|
|
|
|
const bridge = new Bridge();
|
|
|
|
module.exports = bridge;
|