mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00: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.
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
const should = require('should');
|
|
const path = require('path');
|
|
const settingsCache = require('../../../core/server/services/settings/cache');
|
|
const helpers = require('../../../core/frontend/helpers');
|
|
const themeI18n = require('../../../core/frontend/services/theme-engine/i18n');
|
|
const configUtils = require('../../utils/configUtils');
|
|
|
|
describe('{{t}} helper', function () {
|
|
beforeEach(function () {
|
|
configUtils.set('paths:contentPath', path.join(__dirname, '../../utils/fixtures/'));
|
|
});
|
|
|
|
afterEach(function () {
|
|
configUtils.restore();
|
|
settingsCache.shutdown();
|
|
});
|
|
|
|
it('theme translation is DE', function () {
|
|
settingsCache.set('lang', {value: 'de'});
|
|
themeI18n.init('casper');
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
hash: {}
|
|
});
|
|
|
|
rendered.should.eql('Oben Links.');
|
|
});
|
|
|
|
it('theme translation is EN', function () {
|
|
settingsCache.set('lang', {value: 'en'});
|
|
themeI18n.init('casper');
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
hash: {}
|
|
});
|
|
|
|
rendered.should.eql('Left Button on Top');
|
|
});
|
|
|
|
it('[fallback] no theme translation file found for FR', function () {
|
|
settingsCache.set('lang', {value: 'fr'});
|
|
themeI18n.init('casper');
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
hash: {}
|
|
});
|
|
|
|
rendered.should.eql('Left Button on Top');
|
|
});
|
|
|
|
it('[fallback] no theme files at all, use key as translation', function () {
|
|
settingsCache.set('lang', {value: 'de'});
|
|
themeI18n.init('casper-1.4');
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
hash: {}
|
|
});
|
|
|
|
rendered.should.eql('Top left Button');
|
|
});
|
|
});
|