Skip to content

Commit

Permalink
fix tinymce tests
Browse files Browse the repository at this point in the history
due to a issue in country specific language handling introduced in plone#849
  • Loading branch information
petschki authored and tdesvenain committed Aug 14, 2018
1 parent 1b07671 commit 088fdfb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mockup/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define([
if (!self.baseUrl) {
self.baseUrl = '/plonejsi18n';
}
self.currentLanguage = $('html').attr('lang') || 'en-us';
self.currentLanguage = $('html').attr('lang') || 'en';

// Fix for country specific languages
if (self.currentLanguage.split('-').length > 1) {
Expand Down
2 changes: 1 addition & 1 deletion mockup/patterns/tinymce/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ define([
var self = this;
var i18n = new I18n();
var lang = i18n.currentLanguage;
if (lang !== 'en-us' && self.options.tiny.language !== 'en') {
if (lang !== 'en' && self.options.tiny.language !== 'en') {
tinymce.baseURL = self.options.loadingBaseUrl;
// does the expected language exist?
$.ajax({
Expand Down
22 changes: 22 additions & 0 deletions mockup/tests/i18n-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ define([
expect(_('foo')).to.be('bar');
server.restore();
});

it('handles country specific translations', function() {
var i18n = new I18n();
var server = sinon.fakeServer.create();
server.autoRespond = true;
var clock = sinon.useFakeTimers();

server.respondWith('GET', /plonejsi18n/, function (xhr) {
xhr.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({
foo: 'bar-us',
}));
});
i18n.configure({
currentLanguage: 'en-us',
baseUrl: '/plonejsi18n'
});
i18n.loadCatalog('foobar-us');
clock.tick(500);
var _ = i18n.MessageFactory('foobar-us');
expect(_('foo')).to.be('bar-us');
server.restore();
});
});

});
Expand Down

0 comments on commit 088fdfb

Please sign in to comment.