mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 10:53:34 +03:00
33bdd2384b
closes #12271 - When previous active theme did not have locale data for certain language, loading a theme which has such data did not result in correct locale being loaded - Underlying issue was in settings cache being outdated during theme change related i18n initialization - Fix focuses on removing settings cache dependency and and rely on most up to date data about currently active theme - The benefit of this approach is reduced coupling with settings cache
62 lines
1.8 KiB
JavaScript
62 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/themes/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');
|
|
});
|
|
});
|